home *** CD-ROM | disk | FTP | other *** search
/ Compendium Deluxe 1 / LSD Compendium Deluxe 1.iso / a / programming / assembly / kcx25asc.lha / KCX / KCommodity.Asm next >
Encoding:
Assembly Source File  |  1993-06-21  |  346.8 KB  |  13,984 lines

  1.  
  2.         NOLIST
  3. * This can only be assembled under DEVPAC V3.01 since there are many opcodes
  4. * only DEVPAC 3.01 understands. As far as I know.
  5.  
  6. DEBUG        SET    0
  7.  
  8.         OPT    ow-,o+,ow6+,NODEBUG,NOLINE,NOCHKBIT,ALINK
  9.  
  10. *AUTO:        smake KCX
  11.  
  12.  
  13.  
  14. ;* $Revision Header built automatically *************** (do not edit) ************
  15. ;*
  16. ;* © Copyright by GuntherSoft
  17. ;*
  18. ;* File             : SnakeSYS:DevPac/Sources/KCX/WBStartUp/KCX.Asm
  19. ;* Created on       : Sunday, 04-Oct-92 17:00:53
  20. ;* Created by       : Kai Iske
  21. ;* Current revision : V2.5
  22. ;*
  23. ;*
  24. ;* Purpose
  25. ;* -------
  26. ;*     Main KCommodity process, which is responsible for
  27. ;*     all activities
  28. ;*
  29. ;* Revision V2.5
  30. ;* --------------
  31. ;*     --- Initial release ---
  32. ;*
  33. ;*********************************************************************************
  34.  
  35.         XREF    _InvertString
  36.         XREF    _FreeIEvents
  37.         XREF    _HotKey
  38.         XREF    _custom
  39.         XDEF    _CxBase
  40.         XDEF    _SysBase
  41.  
  42. **********************************************************************
  43. *         Local parameters for font-sensitive window open up         *
  44. **********************************************************************
  45.         CARGS    #-(4+4+2+2+2+2),OffY.W,OffX.W,FontY.W,FontX.W,FontPtr.L
  46.  
  47.         IFGT    DEBUG
  48.         XREF    KPrintF
  49.         ENDC
  50.  
  51.         INCLUDE    KCXBase.i
  52.         INCLUDE    KCX_Lib.i
  53.         INCLUDE    KCX.i
  54.  
  55.         INCLUDE    Misc/MyMacros.i
  56.         INCLUDE    Rexx/Errors.i
  57.         INCLUDE    Rexx/Rxslib.i
  58.         INCLUDE    Rexx/Storage.i
  59.         INCLUDE    HardWare/custom.i
  60.  
  61.         IFGT    DEBUG
  62.         INCLUDE    Misc/Debug.i
  63.         ENDC
  64.  
  65.  
  66.  
  67. **********************************************************************
  68. *                Macros for defining the patchtable                  *
  69. **********************************************************************
  70. PATCHES        MACRO
  71. NumPatch    SET    1
  72.         IFEQ    NARG-2
  73.         dc.w    \2,_LVO\1
  74.         dc.l    New\1
  75.         dc.w    Old\1
  76.         ELSE
  77.         FAIL
  78.         ENDC
  79.         ENDM
  80. PATCH        MACRO
  81. NumPatch    SET    NumPatch+1
  82.         IFEQ    NARG-2
  83.         dc.w    \2,_LVO\1
  84.         dc.l    New\1
  85.         dc.w    Old\1
  86.         ELSE
  87.         FAIL
  88.         ENDC
  89.         ENDM
  90.  
  91.  
  92.         SECTION    MyCode,CODE
  93.  
  94. Main        move.l    $4.w,_SysBase
  95.         bra    START
  96.  
  97. **********************************************************************
  98. *                  Versionstring for C:Version-Prg                   *
  99. *       I place it right here, so that it can be found quickly       *
  100. **********************************************************************
  101. VersionString    dc.b    "$VER:KCommodity "
  102.         REVISION
  103.         dc.b    " ("
  104.         REVDATE
  105.         dc.b    ")",0
  106.         EVEN
  107.  
  108. **********************************************************************
  109. *               Fade a layer explode/implode/size/move               *
  110. *                     Vars are passed on stack.                      *
  111. * ScreenAdr                                                          *
  112. * LeftEdge                                                           *
  113. * TopEdge                                                            *
  114. * Width                                                              *
  115. * Height                                                             *
  116. * DeltaX                                                             *
  117. * DeltaY                                                             *
  118. * DeltaWidth                                                         *
  119. * DeltaHeight                                                        *
  120. * Number of Frames to be drawn                                       *
  121. **********************************************************************
  122. LayerFade    CARGS    #8,.Screen.L,.XPos.L,.YPos.L,.LWidth.L,.LHeight.L,.DX.L,.DY.L,.DW.L,.DH.L,.Frames.L
  123.         CARGS    #-36,.Left.L,.Top.L,.Width.L,.Height.L,.LeftStep.L,.TopStep.L,.WidthStep.L,.HeightStep.L,.OldMask.W,.OldMode.W
  124.         bra.s    .Start
  125. .DoSDivMod    lsl.l    #7,d0
  126.         move.l    .Frames(a5),d1
  127.         jmp    _LVOSDivMod32(a6)
  128. .Start        link    a5,#-36
  129.         tst.l    .DX(a5)
  130.         bne.s    .GoOn
  131.         tst.l    .DY(a5)
  132.         bne.s    .GoOn
  133.         tst.l    .DW(a5)
  134.         bne.s    .GoOn
  135.         tst.l    .DH(a5)
  136.         beq    .NoMove
  137. .GoOn        addq.w    #1,SizeUse(a4)
  138.         move.l    _UtilityBase(a4),a6
  139.         move.l    .DX(a5),d0            ; Calc X-Step Rate
  140.         bsr.s    .DoSDivMod
  141.         move.l    d0,.LeftStep(a5)
  142.  
  143.         move.l    .DY(a5),d0            ; Y-Step Rate
  144.         bsr.s    .DoSDivMod
  145.         move.l    d0,.TopStep(a5)
  146.  
  147.         move.l    .DW(a5),d0            ; Width Rate
  148.         bsr.s    .DoSDivMod
  149.         move.l    d0,.WidthStep(a5)
  150.  
  151.         move.l    .DH(a5),d0            ; Height Rate
  152.         bsr.s    .DoSDivMod
  153.         move.l    d0,.HeightStep(a5)
  154.  
  155.         move.l    .Screen(a5),a0
  156.         lea    sc_LayerInfo(a0),a0
  157.         RELLIB    LockLayers,_LayersBase
  158.  
  159.         move.l    .Screen(a5),a0
  160.         lea    sc_LayerInfo(a0),a0
  161.         DOLIB    LockLayerInfo
  162.  
  163.         move.l    .Screen(a5),a3            ; Get address for screen
  164.         lea    sc_RastPort(a3),a0
  165.         move.b    rp_Mask(a0),d0            ; Get old BitPlane-Mask
  166.         ext.w    d0
  167.         move.w    d0,.OldMask(a5)            ; Store Mask
  168.         move.b    #2,rp_Mask(a0)            ; Only allow BitPlane 2 (White color)
  169.         move.b    rp_DrawMode(a0),d0        ; Get old DrawMode
  170.         ext.w    d0
  171.         move.w    d0,.OldMode(a5)            ; Store it
  172.         move.l    a0,a1
  173.         move.l    #RP_COMPLEMENT,d0
  174.         RELLIB    SetDrMd,_GfxBase        ; Set new DrawMode
  175.  
  176.         moveq    #1,d6
  177. .Again        move.l    .XPos(a5),d0            ; copy dims to workbuffer and
  178.         move.l    .YPos(a5),d1            ; calc to our values
  179.         move.l    .LWidth(a5),d2
  180.         move.l    .LHeight(a5),d3
  181.         lsl.l    #7,d0
  182.         lsl.l    #7,d1
  183.         lsl.l    #7,d2
  184.         lsl.l    #7,d3
  185.         move.l    d0,.Left(a5)
  186.         move.l    d1,.Top(a5)
  187.         move.l    d2,.Width(a5)
  188.         move.l    d3,.Height(a5)
  189.  
  190.         move.l    .Frames(a5),d7
  191. .Loop        lea    sc_RastPort(a3),a1        ; Draw Recs. It`s faster than
  192.         move.l    .Left(a5),d0            ; using DrawBorder
  193.         move.l    .Top(a5),d1
  194.         lsr.l    #7,d0
  195.         lsr.l    #7,d1
  196.         tst.w    d0
  197.         bge.s    .X1Ok
  198.         moveq    #0,d0
  199. .X1Ok        tst.w    d1
  200.         bge.s    .Y1Ok
  201.         moveq    #0,d1
  202. .Y1Ok        RELLIB    Move,_GfxBase
  203.  
  204.         lea    sc_RastPort(a3),a1
  205.         move.l    .Left(a5),d0
  206.         add.l    .Width(a5),d0
  207.         move.l    .Top(a5),d1
  208.         lsr.l    #7,d0
  209.         lsr.l    #7,d1
  210.         cmp.w    sc_Width(a3),d0
  211.         blt.s    .W1Ok
  212.         move.w    sc_Width(a3),d0
  213.         subq.w    #1,d0
  214. .W1Ok        tst.w    d1
  215.         bge.s    .Y2Ok
  216.         moveq    #0,d1
  217. .Y2Ok        DOLIB    Draw
  218.  
  219.         lea    sc_RastPort(a3),a1
  220.         move.l    .Left(a5),d0
  221.         add.l    .Width(a5),d0
  222.         move.l    .Top(a5),d1
  223.         add.l    .Height(a5),d1
  224.         lsr.l    #7,d0
  225.         lsr.l    #7,d1
  226.         cmp.w    sc_Width(a3),d0
  227.         blt.s    .W2Ok
  228.         move.w    sc_Width(a3),d0
  229.         subq.w    #1,d0
  230. .W2Ok        cmp.w    sc_Height(a3),d1
  231.         blt.s    .H1Ok
  232.         move.w    sc_Height(a3),d1
  233.         subq.w    #1,d1
  234. .H1Ok        DOLIB    Draw
  235.  
  236.         lea    sc_RastPort(a3),a1
  237.         move.l    .Left(a5),d0
  238.         move.l    .Top(a5),d1
  239.         add.l    .Height(a5),d1
  240.         lsr.l    #7,d0
  241.         lsr.l    #7,d1
  242.         tst.w    d0
  243.         bge.s    .X2Ok
  244.         moveq    #0,d0
  245. .X2Ok        cmp.w    sc_Height(a3),d1
  246.         blt.s    .H2Ok
  247.         move.w    sc_Height(a3),d1
  248.         subq.w    #1,d1
  249. .H2Ok        DOLIB    Draw
  250.  
  251.         lea    sc_RastPort(a3),a1
  252.         move.l    .Left(a5),d0
  253.         move.l    .Top(a5),d1
  254.         lsr.l    #7,d0
  255.         lsr.l    #7,d1
  256.         tst.w    d0
  257.         bge.s    .X3Ok
  258.         moveq    #0,d0
  259. .X3Ok        tst.w    d1
  260.         bge.s    .Y3Ok
  261.         moveq    #0,d1
  262. .Y3Ok        DOLIB    Draw
  263.  
  264.         move.l    .WidthStep(a5),d0
  265.         move.l    .HeightStep(a5),d1
  266.         add.l    d0,.Width(a5)            ; Width/Height decreases
  267.         add.l    d1,.Height(a5)
  268.         move.l    .LeftStep(a5),d0
  269.         move.l    .TopStep(a5),d1
  270.         add.l    d0,.Left(a5)            ; And Left/TopEdge moves
  271.         add.l    d1,.Top(a5)            ; half the way...
  272.         dbf    d7,.Loop
  273.         dbf    d6,.Again            ; Clear frames again
  274.  
  275.         move.l    .Screen(a5),a0            ; Remake Old Mode and Mask
  276.         lea    sc_RastPort(a0),a1
  277.         move.w    .OldMask(a5),d0
  278.         move.b    d0,rp_Mask(a1)
  279.         move.w    .OldMode(a5),d0
  280.         ext.l    d0
  281.         RELLIB    SetDrMd,_GfxBase
  282.         move.l    .Screen(a5),a0
  283.         lea    sc_LayerInfo(a0),a0
  284.         RELLIB    UnlockLayers,_LayersBase
  285.  
  286.         move.l    .Screen(a5),a0
  287.         lea    sc_LayerInfo(a0),a0
  288.         DOLIB    UnlockLayerInfo
  289.  
  290.         subq.w    #1,SizeUse(a4)
  291. .NoMove        unlk    a5
  292.         rts
  293. BackPortName    dc.b    "KCX-BackPort",0
  294. PrefsPortName    dc.b    "KCX-PrefsPort",0
  295.         EVEN
  296.  
  297.  
  298. **********************************************************************
  299. *                            Main program                            *
  300. **********************************************************************
  301. START        movem.l    d1-d7/a0-a6,-(sp)
  302.  
  303.         sub.l    a1,a1
  304.         CALLSYS    FindTask
  305.         move.l    d0,a5
  306.         tst.l    pr_CLI(a5)
  307.         bne.s    .FromCLI
  308.         lea    pr_MsgPort(a5),a0
  309.         DOLIB    WaitPort
  310.         lea    pr_MsgPort(a5),a0
  311.         DOLIB    GetMsg
  312.         move.l    d0,MyWBMsg
  313.  
  314. .FromCLI    move.l    $4.w,a6                ; Test, if we`re running under 2.x
  315.         cmp.w    #NEED_LIBVER,LIB_VERSION(a6)
  316.         bcc.s    .IsOver20
  317.  
  318.         jsr    OnlyKick20
  319.         bra    .EndPrg
  320.  
  321. * First some needed initializations
  322.  
  323. .IsOver20    CALLSYS    Forbid
  324.  
  325.         move.l    #MP_SIZE+4,d0            ; Get memory for our MsgPort
  326.         move.l    #MEMF_CLEAR,d1
  327.         DOLIB    AllocVec
  328.         move.l    d0,d7
  329.         tst.l    d0
  330.         bne.s    .GotComBuff
  331.         DOLIB    Permit
  332.         bra    .OpenError
  333. .GotComBuff    moveq    #-1,d0                ; Try to allocate signal
  334.         DOLIB    AllocSignal
  335.         move.l    d0,d6
  336.         tst.l    d0
  337.         bge.s    .GotComSig
  338.         move.l    d7,a1
  339.         DOLIB    FreeVec
  340.         DOLIB    Permit
  341.         bra    .OpenError
  342. .GotComSig    move.l    d7,a1
  343.         move.b    #PA_SIGNAL,MP_FLAGS(a1)        ; Set Up Message Port structure
  344.         move.b    d6,MP_SIGBIT(a1)
  345.         move.l    ThisTask(a6),MP_SIGTASK(a1)
  346.         lea    MP_MSGLIST(a1),a0
  347.         NEWLIST    a0
  348.         lea    BackPortName(pc),a0
  349.         move.l    a0,LN_NAME(a1)
  350.         move.b    #NT_MSGPORT,LN_TYPE(a1)
  351.         clr.b    LN_PRI(a1)
  352.         moveq    #1,d1
  353.         lsl.l    d6,d1
  354.         move.l    d1,d6
  355.         DOLIB    AddPort                ; Add Port to list
  356.  
  357.         lea    PrefsPortName(pc),a1        ; Buddy there ???
  358.         DOLIB    FindPort
  359.         tst.l    d0
  360.         bne    .TakePrefs
  361.         move.l    #_SIZEOF_PAGE,d0        ; If not, create our ZeroPage
  362.         move.l    #MEMF_CLEAR,d1
  363.         DOLIB    AllocVec
  364.         move.l    d0,ZeroBase
  365.         bne.s    .GotZeroBase
  366.         move.l    d7,a1
  367.         DOLIB    RemPort
  368.         move.l    d6,d0
  369.         DOLIB    FreeSignal
  370.         move.l    d7,a1
  371.         DOLIB    FreeVec
  372.         pea    10
  373.         bra    .NoNothing
  374. .GotZeroBase    move.l    d0,a4
  375.         move.l    d7,BackPort(a4)            ; Store pointer to BackPort
  376.         move.l    d6,BackPortSig(a4)
  377.         bsr    InitZeroPage            ; Init Page
  378.         bsr    InitWindows            ; And windows
  379.         bsr    MakeHotKeys            ; Copy defaults to hotkey buffs
  380.         lea    WindowBase(a4),a0        ; Init Window list header
  381.         NEWLIST    a0
  382.         lea    TaskWinBase(a4),a0
  383.         NEWLIST    a0
  384.         lea    TagScrsTasks(a4),a0
  385.         NEWLIST    a0
  386.         CALLSYS    Permit
  387.         bsr    OpenLibs            ; Open libs
  388.         tst.l    d0
  389.         beq    .OpenError
  390.         move.b    #1,BackFirst(a4)
  391.         bra.s    .GoStart
  392.  
  393. .TakePrefs    move.l    d0,a0                ; Otherwise get buddy`s ZeroPage
  394.         move.l    MP_SIZE(a0),a4
  395.         move.l    a4,ZeroBase
  396.         move.l    d7,BackPort(a4)
  397.         move.l    d6,BackPortSig(a4)
  398.         CALLSYS    Permit
  399.         move.l    PrefsPort(a4),a0
  400.         move.l    BackPort(a4),a1
  401.         move.l    #COM_BACKTHERE,d0
  402.         RELLIB    ComPut,_KCXBase
  403.  
  404. * Patch references; Set up locale and open remaining library
  405.  
  406. .GoStart    move.l    a4,d0
  407.         lea    FormWinWindowTags,a1
  408.         add.l    d0,Zero2+4-FormWinWindowTags(a1)
  409.         add.l    d0,Zero4+4-FormWinWindowTags(a1)
  410.  
  411.         bsr    SetUpLocale            ; Set up the locale
  412.  
  413.         lea    ComName(pc),a1            ; Open Commodities library
  414.         move.l    a1,BackErrArg(a4)
  415.         moveq    #NEED_LIBVER,d0
  416.         CALLSYS    OpenLibrary
  417.         move.l    d0,_CxBase
  418.         beq    .OpenError
  419.  
  420. * Now to the ToolTypes/CommandLine parsing
  421.  
  422.         lea    DefPrefsPath(pc),a0        ; Copy default pathes
  423.         lea    PrefsPath(a4),a1
  424.         bsr    StrCpy
  425.         lea    DefPrintPath(pc),a0
  426.         lea    PrintPath(a4),a1
  427.         bsr    StrCpy
  428.  
  429.         CALLSYS    Forbid
  430.         move.l    ThisTask(a6),a5
  431.         move.l    a5,BackTask(a4)
  432.         move.l    BackPort(a4),a0
  433.         move.l    a4,MP_SIZE(a0)            ; Store pointer to ZeroBase
  434.         DOLIB    Permit
  435.         tst.l    pr_CLI(a5)            ; Did we come from WB ?
  436.         bne.s    .GoOn                ; Yep -> go on
  437.  
  438.         move.l    MyWBMsg(pc),a5            ; Parse ToolTypes
  439.         move.l    sm_ArgList(a5),a5        ; Get pointer to ArgList
  440.         move.l  a5,d0
  441.         beq.s    .GoOn
  442.         move.l    wa_Lock(a5),d1            ; Get lock to Prg-Dir
  443.         RELLIB    CurrentDir,_DOSBase
  444.         move.l    wa_Name(a5),a0            ; Get .info-File
  445.         RELLIB    GetDiskObjectNew,_IconBase
  446.         move.l    d0,MyDiskObj
  447.         beq    .EndPrg
  448.         bsr.s    .GadSub
  449.         move.l    d0,a0                ; Store pointer to ToolTypes
  450.         move.l    do_ToolTypes(a0),MyToolTypes
  451.         bsr    GetToolTypes
  452.         bra.s    .WildThing
  453. .GadSub        move.l    d0,a0                ; Copy Icon`s info to our structure
  454.         lea    do_Gadget(a0),a0
  455.         lea    KCXAppIconDef,a1
  456.         move.l    gg_GadgetRender(a0),AppIconPic-KCXAppIconDef(a1)
  457.         move.w    gg_Width(a0),AppIconWidth-KCXAppIconDef(a1)
  458.         move.w    gg_Height(a0),AppIconHeight-KCXAppIconDef(a1)
  459.         rts
  460. .GoOn        moveq    #WBTOOL,d0
  461.         RELLIB    GetDefDiskObject,_IconBase
  462.         bsr.s    .GadSub
  463.         IFGT    DEBUG
  464.         bra.s    .WildThing
  465.         ENDC
  466.         bsr    GetCommandLine            ; Get command line
  467.         tst.l    d7
  468.         beq    .OpenError
  469.         cmp.l    #1,d7
  470.         beq.s    .WildThing
  471.         moveq    #0,d0
  472.         bra    .CloseDown
  473.  
  474. * Now initialize the main thingies
  475.  
  476. .WildThing    bsr    InitMem                ; Init memory buffers
  477.         tst.l    d0
  478.         beq    .OpenError
  479.  
  480.         tst.b    BackFirst(a4)
  481.         beq.s    .NoToolKey
  482.         bsr    LoadPrefs            ; Read in preferences
  483.         lea    ToolPopUpKey(a4),a0
  484.         tst.b    (a0)
  485.         beq.s    .NoToolKey
  486.         lea    PopUpKey(a4),a1
  487.         bsr    StrCpy
  488. .NoToolKey    lea    StrEditHook,a0            ; Initialize the StringEdit-Hook
  489.         move.l    #MyStrEditFunc,h_Entry(a0)
  490.         clr.l    h_SubEntry(a0)
  491.         move.l    a4,h_Data(a0)
  492.  
  493.         move.l    _GfxBase(a4),a0            ; Check for Denise
  494.         move.b    gb_ChipRevBits0(a0),d0
  495.         btst    #GFXB_HR_DENISE,d0
  496.         beq.s    .NoDenise
  497.         ST    BlackBorderOk(a4)
  498.         jsr    ReBlackBorder
  499.  
  500. .NoDenise    bsr    InitBroker            ; Initialize broker
  501.         tst.l    d0
  502.         beq.s    .OpenError
  503.  
  504.         bsr    InitDrives            ; Check for existing external drives
  505.         bsr    SetNoClick            ; Set/Clear click flag
  506.  
  507.         bsr    InitGfx                ; Initialize graphics
  508.         tst.l    d0
  509.         beq.s    .OpenError
  510.  
  511.         bsr    InitAppIcon            ; Init our AppIcon
  512.  
  513.         bsr    InitAppItem            ; Init AppTools menuitem
  514.  
  515.         bsr    SetPatch            ; Set library patches
  516.  
  517.         tst.b    FlickerOff(a4)            ; Install FlickerIRQ ?
  518.         beq.s    .NoFlicker
  519.         bsr    InitFlickerIRQ            ; Install anti flicker IRQ
  520.  
  521. .NoFlicker    bsr    InitChecker            ; Init the Checker process
  522.         tst.l    CheckerProc(a4)
  523.         beq.s    .OpenError
  524.  
  525.         bsr    InitRexxProc            ; Init Rexx process
  526.         tst.l    RexxProc(a4)
  527.         beq.s    .OpenError
  528.  
  529. .NoInitPop    clr.b    Disabled(a4)
  530.         jsr    EnableBroker            ; Start broker
  531.  
  532.         move.l    BackTask(a4),a1            ; Set user`s priority
  533.         move.l    ToolPri(a4),d0
  534.         CALLSYS    SetTaskPri
  535.         move.l    d0,-(sp)
  536.  
  537.         tst.b    DoPopUp(a4)
  538.         beq.s    .NoPop
  539.         bsr    OpenMainWin
  540.  
  541. .NoPop        bsr    CheckBroker            ; Do the wild thing
  542.  
  543.         move.l    BackTask(a4),a1            ; Reset old Task-Pri
  544.         move.l    (sp)+,d0            ; Necessary when launched from CLI
  545.         CALLSYS    SetTaskPri
  546.         bra.s    .EndPrg
  547.  
  548. .OpenError    tst.l    ErrorBack(a4)            ; Error occured ?
  549.         blt.s    .EndPrg
  550.         jsr    DisplayError            ; Display error
  551. .EndPrg        moveq    #0,d0                ; No error
  552. .CloseDown    move.l    d0,-(sp)
  553.  
  554.         pea    SIGHANDSHAKE
  555.         tst.l    RexxProc(a4)
  556.         beq.s    .NoRexxDown
  557.         move.l    RexxProc(a4),a1            ; Tell Rexx-Proc to go away
  558.         move.l    (sp),d0
  559.         CALLSYS    Signal
  560.         move.l    (sp),d0                ; wait for reply
  561.         DOLIB    Wait
  562.  
  563. .NoRexxDown    tst.l    CheckerProc(a4)
  564.         beq.s    .NoCheckerDown
  565.         move.l    CheckerProc(a4),a1        ; Tell Time-Proc to go away
  566.         move.l    (sp),d0
  567.         CALLSYS    Signal
  568.         move.l    (sp),d0                ; wait for reply
  569.         DOLIB    Wait
  570.  
  571. .NoCheckerDown    tst.l    PrintProc(a4)
  572.         beq.s    .NoPrinterDown
  573.         move.l    PrintProc(a4),a1        ; Tell Printer to go away
  574.         move.l    (sp),d0
  575.         CALLSYS    Signal
  576.         move.l    (sp),d0
  577.         DOLIB    Wait
  578.  
  579. .NoPrinterDown    addq.w    #4,sp
  580.         CALLSYS    Forbid
  581.         tst.l    _KCXBase(a4)
  582.         beq    .NoDiskObj
  583.         bsr    RemFlickerIRQ
  584.         bsr    UnPatch
  585.         bsr    CloseWins            ; Close all windows first
  586.         bsr    RemoveDrives            ; Remove drive structures
  587.         bsr    RemoveAlarmSmp            ; Remove Alarm Sample
  588.         bsr    RemoveAppItems            ; Remove AppMenu
  589.         bsr    RemoveAppIcon            ; Remove AppIcon-Stuff
  590.         bsr    RemoveGfx            ; Remove our gfx
  591.         jsr    DeleteEnvs            ; Remove environment vars
  592.         bsr    RemoveBroker            ; Close resources
  593.  
  594.         tst.l    BackPort(a4)
  595.         beq.s    .NoBackPort
  596.         tst.l    PrefsPort(a4)            ; Prefs port still there ?
  597.         beq.s    .NoPrefsPort
  598.         move.l    PrefsPort(a4),a0        ; Tell Prefs that we leave
  599.         move.l    BackPort(a4),a1
  600.         move.l    #COM_BACKGONE,d0
  601.         RELLIB    ComPut,_KCXBase
  602. .NoPrefsPort    move.l    BackPort(a4),a1            ; Now remove Port
  603.         CALLSYS    RemPort
  604.         move.l    BackPort(a4),a0
  605.         moveq    #0,d0
  606.         move.b    MP_SIGBIT(a0),d0
  607.         DOLIB    FreeSignal
  608.         move.l    BackPort(a4),a1
  609.         DOLIB    FreeVec
  610.         clr.l    BackPort(a4)
  611.         clr.l    BackPortSig(a4)
  612.  
  613. .NoBackPort    bsr    RemoveMem            ; Remove those needed resources
  614.  
  615.         move.l    #NO_ERR,ErrorBack(a4)
  616.         clr.w    QuitBroker(a4)
  617.         clr.b    BackFirst(a4)
  618.  
  619.         move.l    MyDiskObj(pc),d0        ; Got a Disk-Object ?
  620.         beq.s    .NoDiskObj
  621.         move.l    MyDiskObj(pc),a0        ; release it
  622.         RELLIB    FreeDiskObject,_IconBase
  623.  
  624. .NoDiskObj    bsr    ShutDownLocale
  625.  
  626.         lea    PrefsPortName(pc),a1        ; Prefs-Program there ???
  627.         CALLSYS    FindPort
  628.         tst.l    d0
  629.         bne.s    .EndAll
  630.         tst.l    _KCXBase(a4)
  631.         beq.s    .NoWins
  632.         lea    WindowBase(a4),a0
  633.         RELLIB    FreeWindows,_KCXBase        ; Free list of windows
  634.         lea    TaskWinBase(a4),a0
  635.         DOLIB    FreeWindows
  636.         lea    TagScrsTasks(a4),a0
  637.         DOLIB    FreeWindows
  638. .NoWins        bsr    CloseLibs            ; Close libs
  639.         move.l    ZeroBase,a1            ; and remove Data-Block
  640.         CALLSYS    FreeVec
  641.  
  642. .EndAll        move.l    _CxBase,d0
  643.         beq.s    .NoNothing
  644.         move.l    _CxBase,a1
  645.         CALLSYS    CloseLibrary
  646.  
  647. .NoNothing    move.l    MyWBMsg(pc),d0
  648.         beq.s    .NoWBMsg
  649.         move.l    d0,a1
  650.         CALLSYS    ReplyMsg
  651. .NoWBMsg    move.l    (sp)+,d0
  652.         movem.l    (sp)+,d1-d7/a0-a6
  653.         rts
  654. MyWBMsg        dc.l    0
  655. MyToolTypes    dc.l    0
  656. MyDiskObj    dc.l    0
  657. MyRDArgs    dc.l    0
  658. Args        dc.l    0
  659. DefPrefsPath    dc.b    "SYS:Prefs/KCommodity",0
  660. DefPrintPath    dc.b    "SYS:Utilities/KCXPrinter",0
  661.         EVEN
  662.  
  663.  
  664.  
  665. **********************************************************************
  666. *                      Attempt to load the libs                      *
  667. **********************************************************************
  668. OpenLibs    move.l    #NOTFOUND_ERR,ErrorBack(a4)
  669.         lea    KCXName(pc),a1
  670.         move.l    a1,BackErrArg(a4)
  671.         move.l    #VERNUM,d0
  672.         CALLSYS    OpenLibrary
  673.         move.l    d0,_KCXBase(a4)
  674.         tst.l    d0
  675.         beq    .LibError
  676.  
  677.         lea    IntName(pc),a1
  678.         bsr    .LibSub
  679.         move.l    d0,_IntuitionBase(a4)
  680.  
  681.         lea    DosName(pc),a1
  682.         bsr    .LibSub
  683.         move.l    d0,_DOSBase(a4)
  684.  
  685.         lea    IconName(pc),a1
  686.         bsr    .LibSub
  687.         move.l    d0,_IconBase(a4)
  688.  
  689.         lea    LayerName(pc),a1
  690.         bsr    .LibSub
  691.         move.l    d0,_LayersBase(a4)
  692.  
  693.         lea    GadName(pc),a1
  694.         bsr    .LibSub
  695.         move.l    d0,_GadToolsBase(a4)
  696.  
  697.         lea    GfxName(pc),a1
  698.         bsr.s    .LibSub
  699.         move.l    d0,_GfxBase(a4)
  700.  
  701.         lea    RexxSysName(pc),a1
  702.         move.l    a1,BackErrArg(a4)
  703.         moveq    #0,d0
  704.         DOLIB    OpenLibrary
  705.         move.l    d0,_RexxSysBase(a4)
  706.         beq.s    .LibError
  707.  
  708.         lea    AslName(pc),a1
  709.         bsr.s    .LibSub
  710.         move.l    d0,_AslBase(a4)
  711.         move.l    d0,a0
  712.         moveq    #37,d0
  713.         cmp.w    LIB_VERSION(a0),d0
  714.         blt.s    .NoReqTools
  715.         lea    ReqToolsName(pc),a1
  716.         move.l    a1,BackErrArg(a4)
  717.         DOLIB    OpenLibrary
  718.         move.l    d0,_ReqToolsBase(a4)
  719.         beq.s    .LibError
  720.  
  721. .NoReqTools    lea    WBName(pc),a1
  722.         bsr.s    .LibSub
  723.         move.l    d0,_WorkBenchBase(a4)
  724.  
  725.         lea    UtilityName(pc),a1
  726.         bsr.s    .LibSub
  727.         move.l    d0,_UtilityBase(a4)
  728.  
  729.         lea    IFFParseName(pc),a1
  730.         bsr.s    .LibSub
  731.         move.l    d0,_IFFParseBase(a4)
  732.  
  733.         lea    KeyMapName(pc),a1
  734.         bsr.s    .LibSub
  735.         move.l    d0,_KeyMapBase(a4)
  736.  
  737.         lea    LocaleName(pc),a1
  738.         move.l    #NEED_LIBVER,d0
  739.         DOLIB    OpenLibrary
  740.         move.l    d0,_LocaleBase(a4)
  741.         moveq    #1,d0
  742. .LibError    rts
  743. .LibSub        move.l    a1,BackErrArg(a4)
  744.         moveq    #NEED_LIBVER,d0
  745.         CALLSYS    OpenLibrary
  746.         tst.l    d0
  747.         bne.s    .LibSubEnd
  748.         addq.w    #4,sp
  749. .LibSubEnd    rts
  750. **********************************************************************
  751. *                           Library names                            *
  752. **********************************************************************
  753. IntName        dc.b    "intuition.library",0
  754. ComName        dc.b    "commodities.library",0
  755. DosName        dc.b    "dos.library",0
  756. IconName    dc.b    "icon.library",0
  757. LayerName    dc.b    "layers.library",0
  758. GadName        dc.b    "gadtools.library",0
  759. GfxName        dc.b    "graphics.library",0
  760. RexxSysName    dc.b    "rexxsyslib.library",0
  761. WBName        dc.b    "workbench.library",0
  762. AslName        dc.b    "asl.library",0
  763. UtilityName    dc.b    "utility.library",0
  764. IFFParseName    dc.b    "iffparse.library",0
  765. LocaleName    dc.b    "locale.library",0
  766. KeyMapName    dc.b    "keymap.library",0
  767. ReqToolsName    dc.b    "reqtools.library",0
  768. KCXName        KCXNAME
  769.         EVEN
  770.  
  771.  
  772.  
  773.  
  774.  
  775. **********************************************************************
  776. *                          Close Libs again                          *
  777. **********************************************************************
  778. CloseLibs    move.l    $4.w,a6
  779.         tst.l    _KCXBase(a4)
  780.         beq.s    .NoKCX
  781.         move.l    _KCXBase(a4),a1
  782.         DOLIB    CloseLibrary
  783.  
  784. .NoKCX        tst.l    _LocaleBase(a4)
  785.         beq.s    .NoLocale
  786.         move.l    _LocaleBase(a4),a1
  787.         DOLIB    CloseLibrary
  788.  
  789. .NoLocale    tst.l    _KeyMapBase(a4)
  790.         beq.s    .NoKeyMap
  791.         move.l    _KeyMapBase(a4),a1
  792.         DOLIB    CloseLibrary
  793.  
  794. .NoKeyMap    tst.l    _IFFParseBase(a4)
  795.         beq.s    .NoIFFParseBase
  796.         move.l    _IFFParseBase(a4),a1
  797.         DOLIB    CloseLibrary
  798.  
  799. .NoIFFParseBase    tst.l    _UtilityBase(a4)
  800.         beq.s    .NoUtilityBase
  801.         move.l    _UtilityBase(a4),a1
  802.         DOLIB    CloseLibrary
  803.  
  804. .NoUtilityBase    tst.l    _WorkBenchBase(a4)
  805.         beq.s    .NoWBBase
  806.         move.l    _WorkBenchBase(a4),a1
  807.         DOLIB    CloseLibrary
  808.  
  809. .NoWBBase    tst.l    _AslBase(a4)
  810.         beq.s    .NoAslBase
  811.         move.l    _AslBase(a4),a1
  812.         DOLIB    CloseLibrary
  813.  
  814. .NoAslBase    tst.l    _ReqToolsBase(a4)
  815.         beq.s    .NoReqToolsBase
  816.         move.l    _ReqToolsBase(a4),a1
  817.         DOLIB    CloseLibrary
  818.  
  819. .NoReqToolsBase    tst.l    _RexxSysBase(a4)
  820.         beq.s    .NoRexxSysBase
  821.         move.l    _RexxSysBase(a4),a1
  822.         DOLIB    CloseLibrary
  823.  
  824. .NoRexxSysBase    tst.l    _GfxBase(a4)
  825.         beq.s    .NoGfxBase
  826.         move.l    _GfxBase(a4),a1
  827.         DOLIB    CloseLibrary
  828.  
  829. .NoGfxBase    tst.l    _GadToolsBase(a4)
  830.         beq.s    .NoGadToolsBase
  831.         move.l    _GadToolsBase(a4),a1
  832.         DOLIB    CloseLibrary
  833.  
  834. .NoGadToolsBase    tst.l    _LayersBase(a4)
  835.         beq.s    .NoLayersBase
  836.         move.l    _LayersBase(a4),a1
  837.         DOLIB    CloseLibrary
  838.  
  839. .NoLayersBase    tst.l    _IconBase(a4)
  840.         beq.s    .NoIconBase
  841.         move.l    _IconBase(a4),a1
  842.         DOLIB    CloseLibrary
  843.  
  844. .NoIconBase    tst.l    _DOSBase(a4)
  845.         beq.s    .NoDosBase
  846.         move.l    _DOSBase(a4),a1
  847.         DOLIB    CloseLibrary
  848.  
  849. .NoDosBase    tst.l    _IntuitionBase(a4)
  850.         beq.s    .NoIntBase
  851.         move.l    _IntuitionBase(a4),a1
  852.         DOLIB    CloseLibrary
  853. .NoIntBase    rts
  854.  
  855.  
  856.  
  857. **********************************************************************
  858. *                   Set up things for localization                   *
  859. **********************************************************************
  860. SetUpLocale    tst.l    _LocaleBase(a4)            ; Did we have a locale library ?
  861.         beq.s    .NoLocale
  862.         sub.l    a0,a0                ; Open default locale
  863.         RELLIB    OpenLocale,_LocaleBase
  864.         move.l    d0,MyLocale
  865.         sub.l    a0,a0                ; Try to open our catalog
  866.         lea    CatalogName(pc),a1
  867.         sub.l    a2,a2
  868.         DOLIB    OpenCatalogA
  869.         move.l    d0,MyCatalog
  870.         beq.s    .NoLocale
  871.         LOCLEA    DefLabel,a0            ; Copy default drive label to buffer
  872.         lea    FormatDriveName(a4),a1
  873.         bsr    StrCpy
  874. .GotLocale
  875. .NoLocale    rts
  876. MyCatalog    dc.l    0
  877. MyLocale    dc.l    0
  878. CatalogName    dc.b    "kcxmain.catalog",0
  879.         EVEN
  880.  
  881.  
  882. **********************************************************************
  883. *                       Shut down localization                       *
  884. **********************************************************************
  885. ShutDownLocale    tst.l    MyLocale            ; Close default locale
  886.         beq.s    .NoLocale
  887.         move.l    MyLocale(pc),a0
  888.         RELLIB    CloseLocale,_LocaleBase
  889. .NoLocale    tst.l    MyCatalog            ; Close catalog
  890.         beq.s    .NoCatalog
  891.         move.l    MyCatalog,a0
  892.         RELLIB    CloseCatalog,_LocaleBase
  893. .NoCatalog    rts
  894.  
  895.  
  896.  
  897. **********************************************************************
  898. *           Initialize some structures from system-memory            *
  899. **********************************************************************
  900. InitMem        move.l    #AREXXBUFF_ERR,ErrorBack(a4)    ; A small dummy buffer
  901.         move.l    #AREXXBUFFSIZE,d0
  902.         move.l    #MEMF_CLEAR,d1
  903.         CALLSYS    AllocVec
  904.         move.l    d0,ARexxBuffer(a4)
  905. .Error        rts
  906.  
  907.  
  908.  
  909.  
  910. **********************************************************************
  911. *                       Remove used resources                        *
  912. **********************************************************************
  913. RemoveMem    tst.l    ARexxBuffer(a4)            ;  Remove buffer for ARexx
  914.         beq.s    .NoReadBuff
  915.         move.l    ARexxBuffer(a4),a1
  916.         CALLSYS    FreeVec
  917. .NoReadBuff    clr.l    ARexxBuffer(a4)
  918.         rts
  919.  
  920.  
  921.  
  922.  
  923. **********************************************************************
  924. *                Init the Rastport for the title bar                 *
  925. **********************************************************************
  926. InitGfx        link    a5,#-4                ; Lock WB Screen
  927.         bsr    LockScreen
  928.         tst.l    d0
  929.         beq    .NoGfx
  930.  
  931.         move.l    $4.w,a0                ; Determine color of menubar
  932.         cmp.w    #39,LIB_VERSION(a0)
  933.         blt.s    .No30
  934.         move.l    #2,MenuBackPen(a4)
  935.         bra.s    .GotCol
  936. .No30        move.l    #1,MenuBackPen(a4)
  937.  
  938. .GotCol        move.l    d0,a0                ; Get font for titlebar
  939.         move.l    sc_BarLayer(a0),a0
  940.         move.l    lr_rp(a0),a0
  941.         move.l    rp_Font(a0),a0            ; A0 = Font used in bar layer-rastport
  942.         move.l    a0,OldSysFont(a4)
  943.         lea    TxtAttr,a1            ; Store attributes of font
  944.         movem.l    a0/a1,-(sp)
  945.         move.l    LN_NAME(a0),a0
  946.         lea    TxtAttrFont(a4),a2
  947.         move.l    a2,ta_Name(a1)
  948.         move.l    a2,a1
  949.         bsr    StrCpy
  950.         movem.l    (sp)+,a0/a1
  951.         moveq    #0,d7
  952.         move.w    tf_YSize(a0),d7            ; Get height of font
  953.         move.w    d7,ta_YSize(a1)            ; and for bitplanes of title
  954.         move.w    d7,BitMapHeight(a4)
  955.         move.b    tf_Style(a0),ta_Style(a1)
  956.         move.b    tf_Flags(a0),ta_Flags(a1)
  957.  
  958.         move.l    -4(a5),a0
  959.         move.l    sc_RastPort+rp_BitMap(a0),a0    ; Get depth of workbench
  960.         moveq    #0,d0
  961.         move.b    bm_Depth(a0),d0
  962.         move.w    d0,BitMapDepth(a4)
  963.  
  964.         moveq    #0,d1
  965.         move.l    -4(a5),a0
  966.         move.w    sc_Width(a0),d1
  967.         move.w    d1,BitMapWidth(a4)        ; Store sizes
  968.         moveq    #0,d1
  969.         move.b    sc_BarHeight(a0),d1        ; To get the full width and height
  970.                             ; isn`t quite intelligent, but
  971.                             ; it doesn`t take too much memory.
  972.                             ; SO WHAT
  973.  
  974.         move.l    #BITMAP_ERR,ErrorBack(a4)    ; Get mem for BitMap
  975.         move.l    #bm_SIZEOF,d0
  976.         move.l    #MEMF_CLEAR,d1
  977.         CALLSYS    AllocVec
  978.         move.l    d0,MyBitMap(a4)
  979.         beq    .NoGfx
  980.  
  981.         move.l    #RASTPORT_ERR,ErrorBack(a4)    ; Get mem for RastPort
  982.         move.l    #rp_SIZEOF,d0
  983.         move.l    #MEMF_CLEAR,d1
  984.         CALLSYS    AllocVec
  985.         move.l    d0,MyRastPort(a4)
  986.         beq    .NoGfx
  987.  
  988.         move.l    MyBitMap(a4),a0            ; Initialize our BitMap
  989.         move.w    BitMapDepth(a4),d0
  990.         move.w    BitMapWidth(a4),d1
  991.         move.w    BitMapHeight(a4),d2
  992.         RELLIB    InitBitMap,_GfxBase
  993.  
  994.         move.l    #BITPLANE_ERR,ErrorBack(a4)
  995.         move.l    MyBitMap(a4),a3
  996.         lea    bm_Planes(a3),a3        ; Get address of Planes array
  997.         move.w    BitMapDepth(a4),d7        ; Make all planes
  998.         subq.w    #1,d7
  999. .MakeBitMaps    move.w    BitMapWidth(a4),d0
  1000.         move.w    BitMapHeight(a4),d1
  1001.         RELLIB    AllocRaster,_GfxBase
  1002.         tst.l    d0
  1003.         beq.s    .NoGfx
  1004.         move.l    d0,(a3)+
  1005.         dbf    d7,.MakeBitMaps
  1006.  
  1007.         move.l    MyRastPort(a4),a1        ; Init RPort
  1008.         RELLIB    InitRastPort,_GfxBase
  1009.  
  1010.         move.l    MyRastPort(a4),a1
  1011.         move.l    MyBitMap(a4),a0
  1012.         move.l    a0,rp_BitMap(a1)        ; Add pointer of BitMap to RPort
  1013.         move.l    MenuBackPen(a4),d0
  1014.         DOLIB    SetRast
  1015.  
  1016.         move.l    #FONT_ERR,ErrorBack(a4)
  1017.         lea    TxtAttr,a0            ; Try to open font in RAM
  1018.         DOLIB    OpenFont
  1019.         move.l    d0,MyFont(a4)
  1020.         beq.s    .NoGfx                ; THIS SHOULD NEVER HAPPEN
  1021.  
  1022.         move.l    MyRastPort(a4),a1        ; Set font for rastport
  1023.         move.l    d0,a0
  1024.         DOLIB    SetFont
  1025.  
  1026.         move.l    MyRastPort(a4),a1        ; Set draw mode
  1027.         move.l    #RP_JAM1,d0
  1028.         DOLIB    SetDrMd
  1029.  
  1030.         move.l    MyRastPort(a4),a1        ; Set back pen
  1031.         moveq    #1,d0
  1032.         DOLIB    SetBPen
  1033.         move.l    MyRastPort(a4),a1
  1034.         moveq    #0,d0
  1035.         DOLIB    SetAPen
  1036.  
  1037.         move.l    #MEMF_TOTAL,d1            ; Get total available mem
  1038.         CALLSYS    AvailMem
  1039.         move.l    d0,MaxMem(a4)
  1040.  
  1041.         moveq    #1,d0
  1042. .NoGfx        move.l    d0,-(sp)
  1043.         bsr    UnlockScreen
  1044.         move.l    (sp)+,d0
  1045.         unlk    a5
  1046.         rts
  1047.  
  1048.  
  1049.  
  1050. **********************************************************************
  1051. *                    Removes the Gfx areas again                     *
  1052. **********************************************************************
  1053. RemoveGfx    tst.l    MyFont(a4)            ; Did we have a font
  1054.         beq.s    .GotNoFont
  1055.  
  1056.         move.l    MyFont(a4),a1            ; Close font
  1057.         RELLIB    CloseFont,_GfxBase
  1058.  
  1059. .GotNoFont    tst.l    MyRastPort(a4)            ; Free rastport
  1060.         beq.s    .GotNoRastPort
  1061.         move.l    MyRastPort(a4),a1
  1062.         CALLSYS    FreeVec
  1063.  
  1064. .GotNoRastPort    tst.l    MyBitMap(a4)
  1065.         beq.s    .AllFreed
  1066.         move.l    MyBitMap(a4),a5            ; Free bitplanes of BitMap
  1067.         lea    bm_Planes(a5),a5
  1068.         move.w    BitMapDepth(a4),d7
  1069.         subq.w    #1,d7
  1070. .ClearBitPlanes    move.l    (a5)+,d0
  1071.         beq.s    .FreeBitMap
  1072.         move.l    d0,a0
  1073.         move.w    BitMapWidth(a4),d0
  1074.         move.w    BitMapHeight(a4),d1
  1075.         RELLIB    FreeRaster,_GfxBase
  1076.         dbf    d7,.ClearBitPlanes
  1077. .FreeBitMap    move.l    MyBitMap(a4),a1            ; Free bitmap
  1078.         CALLSYS    FreeVec
  1079. .AllFreed    clr.l    MyFont(a4)
  1080.         clr.l    MyRastPort(a4)
  1081.         clr.l    MyBitMap(a4)
  1082.         rts
  1083.  
  1084.  
  1085.  
  1086.  
  1087. **********************************************************************
  1088. *                          Init Audio-Data                           *
  1089. **********************************************************************
  1090. InitAudio    move.l    #AUDIOPORT_ERR,ErrorBack(a4)
  1091.         CALLSYS    CreateMsgPort            ; Create port
  1092.         move.l    d0,AudioPort(a4)
  1093.         beq.s    .AudioError
  1094.         move.l    #AUDIOREQ_ERR,ErrorBack(a4)    ; Create Request
  1095.         move.l    d0,a0
  1096.         clr.l    LN_NAME(a0)
  1097.         clr.b    LN_PRI(a0)
  1098.         move.l    #ioa_SIZEOF,d0
  1099.         DOLIB    CreateIORequest
  1100.         move.l    d0,AudioReq(a4)
  1101.         beq.s    .AudioError
  1102.         move.l    d0,a1
  1103.         move.b    #-50,LN_PRI(a1)
  1104. .AudioError    rts
  1105.  
  1106.  
  1107.  
  1108. **********************************************************************
  1109. *                         Remove Audio-Stuff                         *
  1110. **********************************************************************
  1111. RemoveAudio    tst.l    AudioReq(a4)            ; Remove request
  1112.         beq.s    .NoReq
  1113.         move.l    AudioReq(a4),a0
  1114.         CALLSYS    DeleteIORequest
  1115. .NoReq        tst.l    AudioPort(a4)            ; Remove port
  1116.         beq.s    .NoAudioPort
  1117.         move.l    AudioPort(a4),a0
  1118.         CALLSYS    DeleteMsgPort
  1119. .NoAudioPort    clr.l    AudioReq(a4)
  1120.         clr.l    AudioPort(a4)
  1121.         rts
  1122.  
  1123.  
  1124.  
  1125. **********************************************************************
  1126. *                     Initialize the ARexx Port                      *
  1127. **********************************************************************
  1128. InitARexx    move.l    #AREXXPORT_ERR,ErrorBack(a4)
  1129.         CALLSYS    CreateMsgPort            ; Create a Msg Port for ARexx
  1130.         move.l    d0,ARexxPort(a4)
  1131.         beq.s    .ARexxError
  1132.         move.l    d0,a1
  1133.         moveq    #0,d0
  1134.         moveq    #1,d1
  1135.         move.b    MP_SIGBIT(a1),d0        ; Get Sig flag
  1136.         lsl.l    d0,d1
  1137.         move.l    d1,ARexxSigFlag(a4)
  1138.         lea    ARexxPortName(pc),a0
  1139.         move.l    a0,LN_NAME(a1)
  1140.         clr.b    LN_PRI(a1)
  1141.         DOLIB    AddPort                ; Add port to system
  1142.         moveq    #1,d0
  1143.         clr.l    ErrorBack(a4)
  1144. .ARexxError    rts
  1145. ARexxPortName    dc.b    "KComm.1",0
  1146.         ds.b    10
  1147.         EVEN
  1148.  
  1149.  
  1150. **********************************************************************
  1151. *                 Remove our ARexx port from System                  *
  1152. **********************************************************************
  1153. RemoveARexx    tst.l    ARexxPort(a4)
  1154.         beq.s    .NoARexxPort
  1155.         move.l    ARexxPort(a4),a1
  1156.         bsr    KillMessages            ; Kill remaining messages
  1157.         CALLSYS    RemPort                ; Remove port
  1158.         move.l    ARexxPort(a4),a0
  1159.         DOLIB    DeleteMsgPort
  1160. .NoARexxPort    clr.l    ARexxPort(a4)
  1161.         rts
  1162.  
  1163.  
  1164.  
  1165.  
  1166. **********************************************************************
  1167. *                 This the table for all the patches                 *
  1168. **********************************************************************
  1169. PatchTable    PATCHES    OpenScreen,_IntuitionBase
  1170.         PATCH    OpenScreenTagList,_IntuitionBase
  1171.         PATCH    ScreenToFront,_IntuitionBase
  1172.         PATCH    ScreenToBack,_IntuitionBase
  1173.         PATCH    WBenchToFront,_IntuitionBase
  1174.         PATCH    WBenchToBack,_IntuitionBase
  1175.         PATCH    CloseScreen,_IntuitionBase
  1176.         PATCH    AutoRequest,_IntuitionBase
  1177.         PATCH    EasyRequestArgs,_IntuitionBase
  1178.         PATCH    CreateUpfrontLayer,_LayersBase
  1179.         PATCH    CreateUpfrontHookLayer,_LayersBase
  1180.         PATCH    DeleteLayer,_LayersBase
  1181.         PATCH    MoveSizeLayer,_LayersBase
  1182.         PATCH    DisplayBeep,_IntuitionBase
  1183.         PATCH    MatchFirst,_DOSBase
  1184.         PATCH    OpenWorkBench,_IntuitionBase
  1185.         PATCH    CloseWorkBench,_IntuitionBase
  1186.  
  1187.  
  1188. **********************************************************************
  1189. *                          Set all patches                           *
  1190. **********************************************************************
  1191. SetPatch    lea    PatchTable(pc),a2        ; Work all patches
  1192.         moveq    #NumPatch-1,d7
  1193. .Loop        move.w    0(a2),d0
  1194.         move.l    0(a4,d0.w),a1
  1195.         move.w    2(a2),a0
  1196.         move.l    4(a2),d0
  1197.         move.l    a1,d1
  1198.         beq.s    .NoPatch
  1199.         CALLSYS    SetFunction
  1200.         move.w    8(a2),d1
  1201.         move.l    d0,0(a4,d1.w)
  1202. .NoPatch    lea    10(a2),a2
  1203.         dbf    d7,.Loop
  1204.         rts
  1205.  
  1206.  
  1207. **********************************************************************
  1208. *                     Remove all of our patches                      *
  1209. **********************************************************************
  1210. UnPatch        lea    PatchTable(pc),a2        ; Unpatch system library vectors
  1211.         moveq    #NumPatch-1,d7
  1212. .Loop        move.w    0(a2),d0
  1213.         move.l    0(a4,d0.w),a1
  1214.         move.w    2(a2),a0
  1215.         move.w    8(a2),d1
  1216.         move.l    0(a4,d1.w),d0
  1217.         beq.s    .NoPatch
  1218.         clr.l    0(a4,d1.w)
  1219.         move.l    a1,d1
  1220.         beq.s    .NoPatch
  1221.         CALLSYS    SetFunction
  1222. .NoPatch    lea    10(a2),a2
  1223.         dbf    d7,.Loop
  1224.         rts
  1225.  
  1226.  
  1227. **********************************************************************
  1228. *            Install VertB interrupt to avoid flickering             *
  1229. **********************************************************************
  1230. InitFlickerIRQ    tst.b    IRQSet(a4)
  1231.         bne.s    .End
  1232.         lea    FlickerIRQ(a4),a1        ; Start the flicker IRQ
  1233.         lea    FlickerName(pc),a0
  1234.         move.l    a0,LN_NAME(a1)
  1235.         move.b    #NT_INTERRUPT,LN_TYPE(a1)
  1236.         clr.b    LN_PRI(a1)
  1237.         lea    FlickerRout(pc),a0
  1238.         move.l    a0,IS_CODE(a1)
  1239.         move.l    a4,IS_DATA(a1)
  1240.         moveq    #INTB_VERTB,d0
  1241.         CALLSYS    AddIntServer
  1242.         ST    IRQSet(a4)
  1243. .End        rts
  1244. FlickerName    dc.b    "KCX Anti-Flicker IRQ",0
  1245.         EVEN
  1246.  
  1247.  
  1248.  
  1249. **********************************************************************
  1250. *                      Remove Anti-Flicker IRQ                       *
  1251. **********************************************************************
  1252. RemFlickerIRQ    tst.b    IRQSet(a4)
  1253.         beq.s    .End
  1254.         lea    FlickerIRQ(a4),a1
  1255.         moveq    #INTB_VERTB,d0
  1256.         CALLSYS    RemIntServer
  1257.         SF    IRQSet(a4)
  1258. .End        rts
  1259.  
  1260.  
  1261. **********************************************************************
  1262. *                 Small and simple, avoid flicker :)                 *
  1263. **********************************************************************
  1264. FlickerRout    tst.b    FlickerOff(a1)
  1265.         beq.s    .End
  1266.         OPT    NOCHKIMM
  1267.         lea    $dff000,a0
  1268.         OPT    CHKIMM
  1269.         clr.w    color(a0)            ; Set background color to 0
  1270. .End        moveq    #0,d0
  1271.         rts
  1272.  
  1273.  
  1274.  
  1275. **********************************************************************
  1276. *                    Initialize and start broker                     *
  1277. **********************************************************************
  1278. InitBroker    bsr    RemoveBroker            ; Begin from scratch
  1279.  
  1280.         move.l    #SIGNAL_ERR,ErrorBack(a4)
  1281.  
  1282.         moveq    #-1,d0                ; Try to allocate signal for
  1283.         CALLSYS    AllocSignal            ; alarm
  1284.         move.l    d0,AlarmSigBit(a4)
  1285.         blt    .NoBroker
  1286.         moveq    #1,d1
  1287.         lsl.l    d0,d1
  1288.         move.l    d1,AlarmSigFlag(a4)
  1289.  
  1290.         moveq    #-1,d0                ; Allocate signal for formatter
  1291.         DOLIB    AllocSignal
  1292.         move.l    d0,FormatSigBit(a4)
  1293.         blt    .NoBroker
  1294.         moveq    #1,d1
  1295.         lsl.l    d0,d1
  1296.         move.l    d1,FormatSigFlag(a4)
  1297.  
  1298.         moveq    #-1,d0                ; Allocate signal for dragging
  1299.         DOLIB    AllocSignal
  1300.         move.l    d0,DragSigBit(a4)
  1301.         blt    .NoBroker
  1302.         moveq    #1,d1
  1303.         lsl.l    d0,d1
  1304.         move.l    d1,DragSigFlag(a4)
  1305.  
  1306.         lea    MySemaphore(a4),a0        ; Initialize our Semphore
  1307.         DOLIB    InitSemaphore
  1308.  
  1309.         lea    PortName(pc),a1            ; Find port name
  1310.         DOLIB    FindPort            ; This is for identification
  1311.         move.l    d0,DoublePort(a4)        ; whether we are to quit
  1312.  
  1313.         move.l    #BROKERPORT_ERR,ErrorBack(a4)
  1314.         DOLIB    CreateMsgPort            ; Try to set msg-port
  1315.         move.l    d0,BrokerPort(a4)
  1316.         beq    .NoBroker
  1317.         move.l    d0,a1
  1318.         moveq    #1,d0
  1319.         moveq    #0,d1
  1320.         move.b    MP_SIGBIT(a1),d1
  1321.         lsl.l    d1,d0
  1322.         move.l    d0,BrokerSigFlag(a4)        ; Calc sig-flag
  1323.         lea    PortName(pc),a0
  1324.         move.l    a0,LN_NAME(a1)
  1325.         move.b    #5,LN_PRI(a1)
  1326.         DOLIB    AddPort                ; Add port to system
  1327.  
  1328.         move.l    #BROKER_ERR,ErrorBack(a4)
  1329.         lea    MyBrokerDef,a0            ; Create broker
  1330.         LOCLEA    BrokerTitle,nb_Title(a0)
  1331.         LOCLEA    BrokerDesc,nb_Descr(a0)
  1332.         move.l    BrokerPort(a4),nb_Port(a0)    ; add Port-Address
  1333.         move.l    CxPri(a4),d0
  1334.         move.b    d0,nb_Pri(a0)            ; and Priority
  1335.         moveq    #0,d0                ; No errors
  1336.         LNKLIB    CxBroker,_CxBase        ; install broker structure
  1337.         tst.l    d0
  1338.         beq.s    .NoBroker
  1339.         move.l    d0,MyBroker(a4)
  1340.  
  1341.         lea    DefaultHotKeys,a0        ; Init HotKeys
  1342.         lea    HotKeyGadVars,a1
  1343.         lea    HotKeyGadStat,a2
  1344.         move.l    #POPUPKEYID,d6
  1345.         move.w    #HOTKEYNUM-1,d7
  1346. .InitHKs    move.l    8(a1),-(sp)
  1347.         move.l    d6,-(sp)
  1348.         move.l    (a0)+,-(sp)
  1349.         move.l    (a2)+,-(sp)
  1350.         bsr    InstallHotKey
  1351.         lea    16(sp),sp
  1352.         tst.l    d0
  1353.         beq.s    .NoBroker
  1354.         lea    12(a1),a1
  1355.         addq.l    #1,d6
  1356.         dbf    d7,.InitHKs
  1357.  
  1358.         move.l    #BROKERUP_ERR,ErrorBack(a4)
  1359.         move.l    MyBroker(a4),a0            ; Check for an error in broker
  1360.         DOLIB    CxObjError
  1361.         tst.l    d0
  1362.         bne.s    .NoBroker
  1363.  
  1364.         jsr    DisableBroker            ; Disable broker for now
  1365.         move.b    #1,Disabled(a4)
  1366.         moveq    #1,d0                ; No error
  1367.         rts
  1368. .NoBroker    moveq    #0,d0                ; error occured
  1369.         rts
  1370. PortName    dc.b    "KComm-BrokerPort",0
  1371.         EVEN
  1372.  
  1373.  
  1374.  
  1375. **********************************************************************
  1376. *                         Remove the broker                          *
  1377. **********************************************************************
  1378. RemoveBroker    tst.l    MyBroker(a4)
  1379.         beq.s    .NoBroker
  1380.         clr.b    Disabled(a4)            ; Disable broker
  1381.         jsr    DisableBroker
  1382.         move.l    MyBroker(a4),a0            ; Delete broker
  1383.         LNKLIB    DeleteCxObjAll,_CxBase
  1384. .NoBroker    tst.l    BrokerPort(a4)            ; Remove broker and all
  1385.         beq.s    .NoPort                ; attached objects
  1386.         move.l    BrokerPort(a4),a1
  1387.         bsr    KillMessages            ; remove messages
  1388.         CALLSYS    RemPort
  1389.         move.l    BrokerPort(a4),a0        ; Finally delete the
  1390.         DOLIB    DeleteMsgPort            ; Messageport
  1391. .NoPort        tst.l    AlarmSigBit(a4)
  1392.         blt.s    .NoSigBit
  1393.         move.l    AlarmSigBit(a4),d0
  1394.         CALLSYS    FreeSignal            ; Free Alarm-Signal
  1395. .NoSigBit    tst.l    FormatSigBit(a4)
  1396.         blt.s    .NoFormSig
  1397.         move.l    FormatSigBit(a4),d0
  1398.         CALLSYS    FreeSignal
  1399. .NoFormSig    tst.l    DragSigBit(a4)
  1400.         blt.s    .NoDragSig
  1401.         move.l    DragSigBit(a4),d0
  1402.         CALLSYS    FreeSignal
  1403. .NoDragSig    clr.l    MyBroker(a4)
  1404.         clr.l    BrokerPort(a4)
  1405.         moveq    #-1,d0
  1406.         move.l    d0,AlarmSigBit(a4)
  1407.         move.l    d0,DragSigBit(a4)
  1408.         move.l    d0,FormatSigBit(a4)
  1409.         rts
  1410.  
  1411.  
  1412.  
  1413. **********************************************************************
  1414. *                      Install the InputHandler                      *
  1415. **********************************************************************
  1416. InitHandler    move.l    #INPUTPORT_ERR,ErrorBack(a4)
  1417.         DOLIB    CreateMsgPort            ; Create a Port
  1418.         move.l    d0,InputPort(a4)
  1419.         beq.s    .Error
  1420.         move.l    d0,a1
  1421.         clr.b    LN_PRI(a1)
  1422.         clr.l    LN_NAME(a1)
  1423.  
  1424.         move.l    InputPort(a4),a0
  1425.         move.l    #IOSTD_SIZE,d0
  1426.         DOLIB    CreateIORequest
  1427.         move.l    d0,InputReq(a4)
  1428.         tst.l    d0
  1429.         beq.s    .Error
  1430.  
  1431.         move.l    #NOTFOUND_ERR,ErrorBack(a4)
  1432. .LoopOpen    lea    InputName(pc),a0        ; Try to open the device
  1433.         move.l    a0,BackErrArg(a4)
  1434.         move.l    InputReq(a4),a1
  1435.         moveq    #0,d0
  1436.         moveq    #0,d1
  1437.         DOLIB    OpenDevice
  1438.         tst.l    d0
  1439.         bne.s    .LoopOpen
  1440.  
  1441.         move.l    #HANDLER_ERR,ErrorBack(a4)
  1442.         lea    HandlerIRQ(a4),a0        ; Set up Handler
  1443.         move.l    a4,IS_DATA(a0)
  1444.         move.l    #RawEventAction,IS_CODE(a0)
  1445.         move.l    HandlerPri(a4),d0        ; Set priority
  1446.         move.b    d0,LN_PRI(a0)
  1447.         lea    HandlerName(pc),a2
  1448.         move.l    a2,LN_NAME(a0)
  1449.         move.l    InputReq(a4),a1
  1450.         move.l    a0,IO_DATA(a1)
  1451.         move.w    #IND_ADDHANDLER,IO_COMMAND(a1)
  1452.         DOLIB    DoIO
  1453. .End        moveq    #1,d0
  1454.         rts
  1455. .Error        moveq    #0,d0
  1456.         rts
  1457. InputName    dc.b    "input.device",0
  1458. HandlerName    dc.b    "KComm-InputHandler",0
  1459.         EVEN
  1460.  
  1461.  
  1462.  
  1463. **********************************************************************
  1464. *                        Remove InputHandler                         *
  1465. **********************************************************************
  1466. RemoveHandler    move.l    InputReq(a4),a1
  1467.         tst.l    IO_DEVICE(a1)
  1468.         beq.s    .NoDevice
  1469.         lea    HandlerIRQ(a4),a0
  1470.         move.l    a0,IO_DATA(a1)            ; Remove Handler
  1471.         move.w    #IND_REMHANDLER,IO_COMMAND(a1)
  1472.         CALLSYS    DoIO
  1473.         move.l    InputReq(a4),a1            ; Close device
  1474.         CALLSYS    CloseDevice
  1475. .NoDevice    tst.l    InputReq(a4)
  1476.         beq.s    .NoReq
  1477.         move.l    InputReq(a4),a0
  1478.         CALLSYS    DeleteIORequest
  1479. .NoReq        tst.l    InputPort(a4)
  1480.         beq.s    .NoPort                ; Delete message
  1481.         move.l    InputPort(a4),a0
  1482.         CALLSYS    DeleteMsgPort
  1483. .NoPort        clr.l    InputPort(a4)
  1484.         clr.l    InputReq(a4)
  1485.         rts
  1486.  
  1487.  
  1488.  
  1489. **********************************************************************
  1490. *           Add an AppIcon. This one uses the Broker-Port            *
  1491. **********************************************************************
  1492. InitAppIcon    CALLSYS    CreateMsgPort            ; Create Msg-Port
  1493.         move.l    d0,AppPort(a4)
  1494.         beq.s    .Error
  1495.         move.l    d0,a1
  1496.         clr.b    LN_PRI(a1)
  1497.         clr.l    LN_NAME(a1)
  1498.         moveq    #0,d0
  1499.         moveq    #1,d1
  1500.         move.b    MP_SIGBIT(a1),d0
  1501.         lsl.l    d0,d1
  1502.         move.l    d1,AppSigFlag(a4)        ; Get SigFlag
  1503.         moveq    #1,d0
  1504.         tst.b    DispAppIcon(a4)
  1505.         beq.s    .End
  1506.         jsr    OnAppIcon
  1507.         bra.s    .End
  1508. .Error        move.l    #APPICON_ERR,ErrorBack(a4)
  1509.         jsr    DisplayError
  1510. .End        rts
  1511.  
  1512.  
  1513.  
  1514. **********************************************************************
  1515. *                         Remove our AppIcon                         *
  1516. **********************************************************************
  1517. RemoveAppIcon    jsr    OffAppIcon
  1518.         tst.l    AppPort(a4)
  1519.         beq.s    .NoPort
  1520.         move.l    AppPort(a4),a1            ; Clear all pending messages
  1521.         bsr    KillMessages
  1522.         move.l    AppPort(a4),a0
  1523.         CALLSYS    DeleteMsgPort
  1524. .NoPort        clr.l    AppPort(a4)
  1525.         rts
  1526.  
  1527.  
  1528.  
  1529.  
  1530. **********************************************************************
  1531. *               Add some menu items to the tools menu                *
  1532. **********************************************************************
  1533. InitAppItem    tst.b    DispAppMenu(a4)
  1534.         beq.s    .End
  1535.         move.l    #MAINITEM,d0            ; Create an item
  1536.         moveq    #0,d1
  1537.         LOCLEA    AppMenuTxt,a0
  1538.         move.l    AppPort(a4),a1
  1539.         sub.l    a2,a2
  1540.         RELLIB    AddAppMenuItemA,_WorkBenchBase
  1541.         move.l    d0,KCXAppMenuItem(a4)
  1542.         bne.s    .End
  1543.         move.l    #APPMENU_ERR,ErrorBack(a4)
  1544.         bsr    DisplayError
  1545. .End        rts
  1546.  
  1547.  
  1548.  
  1549.  
  1550. **********************************************************************
  1551. *                    Remove our menu items again                     *
  1552. **********************************************************************
  1553. RemoveAppItems    tst.l    KCXAppMenuItem(a4)
  1554.         beq.s    .NoRemove
  1555.         move.l    KCXAppMenuItem(a4),a0
  1556.         RELLIB    RemoveAppMenuItem,_WorkBenchBase
  1557. .NoRemove    clr.l    KCXAppMenuItem(a4)
  1558.         rts
  1559.  
  1560.  
  1561.  
  1562.  
  1563. **********************************************************************
  1564. *          Try to set a hotkey. Inputs are given on stack :          *
  1565. * 1. HotKey Definition                                               *
  1566. * 2. Default HotKey Definition                                       *
  1567. * 3. HotKey ID                                                       *
  1568. * 4. Address of filter                                               *
  1569. **********************************************************************
  1570. InstallHotKey    CARGS    #68,HotKey.l,DefHotKey.l,ID.l,Filter.l
  1571.         movem.l    RegsAll,-(sp)
  1572.         link    a5,#-HOTKEYSIZE
  1573.         move.l    #HOTKEY_ERR,ErrorBack(a4)
  1574.         move.l    ID(a5),-(sp)
  1575.         move.l    BrokerPort(a4),-(sp)
  1576.         move.l    HotKey(a5),a0
  1577.         add.l    a4,a0
  1578.         lea    NonName(pc),a1
  1579.         moveq    #-1,d7
  1580.         bsr    StrCmp
  1581.         tst.l    d0
  1582.         bne.s    .NormalHotKey
  1583.         lea    NonHotKey(pc),a0
  1584. .NormalHotKey    move.l    a0,-(sp)
  1585.         jsr    _HotKey
  1586.         lea    12(sp),sp
  1587.         tst.l    d0
  1588.         bne.s    .GotUserHotKey            ; Got it -> go on
  1589.         move.l    HotKey(a5),a0            ; Clone user-hotkey
  1590.         add.l    a4,a0
  1591.         lea    -HOTKEYSIZE(a5),a1
  1592.         bsr    StrCpy
  1593.         move.l    DefHotKey(a5),a0        ; Try default
  1594.         move.l    a0,BackErrArg(a4)
  1595.         move.l    HotKey(a5),a1
  1596.         add.l    a4,a1
  1597.         bsr    StrCpy                ; First copy it
  1598.         move.l    ID(a5),-(sp)
  1599.         move.l    BrokerPort(a4),-(sp)
  1600.         move.l    DefHotKey(a5),-(sp)
  1601.         jsr    _HotKey
  1602.         lea    12(sp),sp
  1603.         tst.l    d0
  1604.         bne.s    .GotDefHotKey            ; Error ???
  1605.         bsr    DisplayError            ; Display error
  1606.         bra.s    .Error
  1607. .GotDefHotKey    move.l    #USERHOTKEY_ERR,ErrorBack(a4)    ; Tell user we`re using ours
  1608.         lea    -HOTKEYSIZE(a5),a0
  1609.         move.l    a0,BackErrArg(a4)
  1610.         move.l    DefHotKey(a5),BackErrArg2(a4)
  1611.         bsr    DisplayError
  1612. .GotUserHotKey    move.l    Filter(a5),a0
  1613.         add.l    a4,a0
  1614.         move.l    d0,(a0)
  1615.         move.l    MyBroker(a4),a0
  1616.         move.l    d0,a1
  1617.         LNKLIB    AttachCxObj,_CxBase        ; Attach hotkey stuff
  1618.         unlk    a5
  1619.         movem.l    (sp)+,RegsAll
  1620.         moveq    #1,d0
  1621.         rts
  1622. .Error        unlk    a5
  1623.         movem.l    (sp)+,RegsAll
  1624.         moveq    #0,d0
  1625.         rts
  1626. NonName        dc.b    "none",0
  1627. NonHotKey    dc.b    "lshift lalt lcommand rshift ralt rcommand control numericpad esc",0
  1628.         EVEN
  1629.  
  1630.  
  1631.  
  1632.  
  1633.  
  1634. **********************************************************************
  1635. *                        Init Windowpositions                        *
  1636. **********************************************************************
  1637. InitWindows    lea    WinPosTab(pc),a2        ; Copy default window pos/sizes to "BSS"
  1638.         lea    MainWinLeft(a4),a3
  1639.         moveq    #43,d0
  1640. .loop1        move.w    (a2)+,(a3)+
  1641.         dbf    d0,.loop1
  1642.         lea    WinSizeTab(pc),a2
  1643.         lea    MainWinWidth(a4),a3
  1644.         moveq    #43,d0
  1645. .loop2        move.w    (a2)+,(a3)+
  1646.         dbf    d0,.loop2
  1647.         rts
  1648. WinPosTab    dc.w    58,37,44,46,57,44,133,67
  1649.         dc.w    110,82,118,53,167,61,70,51
  1650.         dc.w    78,68,168,40,138,13,120,65
  1651.         dc.w    397,11,120,17,65,50,166,68
  1652.         dc.w    0,0,70,23,55,51,139,73
  1653.         dc.w    72,55,103,75
  1654. WinSizeTab    dc.w    551,126,574,45,583,126,484,79
  1655.         dc.w    421,35,424,94,348,78,527,147
  1656.         dc.w    562,95,356,111,364,173,507,100
  1657.         dc.w    319,106,485,180,511,100,309,23
  1658.         dc.w    0,0,608,162,592,96,405,82
  1659.         dc.w    523,180,450,101
  1660.  
  1661.  
  1662.  
  1663.  
  1664.  
  1665. **********************************************************************
  1666. *                      Init ZeroPage-Parameters                      *
  1667. **********************************************************************
  1668. InitZeroPage    moveq    #-1,d0
  1669.         move.l    d0,FCycleSecs(a4)        ; Init some longs
  1670.         move.l    d0,BCycleSecs(a4)
  1671.         move.l    d0,MCycleSecs(a4)
  1672.         move.w    d0,OldX(a4)
  1673.         move.l    d0,ThisHour(a4)
  1674.         move.l    d0,AlarmSigBit(a4)
  1675.         move.l    d0,FormatSigBit(a4)
  1676.         move.l    d0,DragSigBit(a4)
  1677.         move.l    d0,LastSelScrSec(a4)
  1678.         move.l    d0,LastSelScrMin(a4)
  1679.         move.w    d0,LastSelScr(a4)
  1680.  
  1681.         moveq    #1,d0
  1682.         move.b    d0,DoPopUp(a4)            ; Set some bool flags
  1683.         move.b    d0,TimeReset(a4)
  1684.         move.b    d0,DispAppIcon(a4)
  1685.         move.b    d0,DispAppMenu(a4)
  1686.         move.b    d0,CheckQuit(a4)
  1687.  
  1688.         move.b    d0,DoActivate(a4)        ; Init default settings
  1689.         move.b    d0,ShowClock(a4)
  1690.         move.b    d0,DoShowTime(a4)
  1691.         move.b    d0,ShowSecs(a4)
  1692.         move.b    d0,DoShowAlarm(a4)
  1693.         move.b    d0,CycleWin(a4)
  1694.         move.b    d0,KeyClick(a4)
  1695.         move.b    d0,BillPopUp(a4)
  1696.         move.b    d0,WBFront(a4)
  1697.         move.b    d0,ESCClose(a4)
  1698.  
  1699.         move.b    d0,MakeIcons(a4)
  1700.         move.b    d0,QuickFormat(a4)
  1701.         move.b    d0,FFSDrive(a4)
  1702.         move.b    d0,WatchDisks(a4)
  1703.         move.b    d0,MMBShift(a4)
  1704.         move.b    d0,LogCalls(a4)
  1705.         move.b    d0,Saturday(a4)
  1706.         move.b    d0,Sunday(a4)
  1707.         move.b    d0,MouseEver(a4)
  1708.         move.b    d0,DriveNoClick(a4)
  1709.         move.b    d0,GfxCenter(a4)
  1710.         move.b    d0,GfxFormFeed(a4)
  1711.         move.b    d0,GfxKeepAspect(a4)
  1712.         move.b    d0,Watch0(a4)
  1713.         move.b    d0,WindowReAct(a4)
  1714.  
  1715.         moveq    #2,d1
  1716.         move.w    #300,ScreenTime+2(a4)
  1717.         move.b    #10,MouseTime+3(a4)
  1718.         move.b    #64,ClickVol+3(a4)
  1719.         move.b    #5,DimmValue+3(a4)
  1720.         move.b    #20,ExpFrames+3(a4)
  1721.         move.b    #20,ImpFrames+3(a4)
  1722.         move.b    #15,SizeFrames+3(a4)
  1723.         move.b    #15,MoveFrames+3(a4)
  1724.         move.b    #4,Accelerate+3(a4)
  1725.         move.b    d1,ThresHold+3(a4)
  1726.         move.w    #IECODE_LBUTTON,FrontCode(a4)
  1727.         move.w    #IECODE_RBUTTON,BackCode(a4)
  1728.         move.w    #IEQUALIFIER_LEFTBUTTON,BackQual(a4)
  1729.         move.w    #IEQUALIFIER_LALT,ESCQual(a4)
  1730.         move.w    d1,FrontClicks(a4)
  1731.         move.w    d1,BackClicks(a4)
  1732.         move.w    d1,MiddleClicks(a4)
  1733.         move.l    #8*6,CheapStop(a4)
  1734.         move.l    #18*6,CheapStart(a4)
  1735.         move.l    #MAXBARLEN,MaxBarLen(a4)
  1736.  
  1737.         move.l    $4.w,a6
  1738.         cmp.w    #39,LIB_VERSION(a6)
  1739.         blt.s    .No30
  1740.         move.l    d0,TextFrontPen(a4)
  1741.         move.l    d1,TextBackPen(a4)
  1742.         clr.l    GaugeFrontPen(a4)
  1743.         move.b    #3,GaugeBackPen+3(a4)
  1744.         bra.s    .GotCols
  1745. .No30        clr.l    TextFrontPen(a4)
  1746.         move.l    d0,TextBackPen(a4)
  1747.         move.b    #3,GaugeFrontPen+3(a4)
  1748.         clr.l    GaugeBackPen(a4)
  1749.  
  1750. .GotCols    move.w    #IEQUALIFIER_LSHIFT,FullDragQual(a4)
  1751.         move.w    #360,CostUnit1+2(a4)
  1752.         move.w    #720,CostUnit1+6(a4)
  1753.         move.b    #60,CostUnit2+3(a4)
  1754.         move.b    #120,CostUnit2+7(a4)
  1755.         move.b    #21,CostUnit3+3(a4)
  1756.         move.b    #42,CostUnit3+7(a4)
  1757.         move.b    #23,CostUnit+3(a4)
  1758.         move.b    #4,GfxScale+3(a4)
  1759.         move.b    #2,GfxDensity+3(a4)
  1760.         move.b    #4,GfxThreshold+3(a4)
  1761.         move.l    #NO_ERR,ErrorBack(a4)
  1762.         move.b    #55,HandlerPri+3(a4)
  1763.         move.w    #IEQUALIFIER_LALT,HoldXQual(a4)
  1764.         move.w    #IEQUALIFIER_CONTROL,HoldYQual(a4)
  1765.  
  1766.         move.w    #640-236,BillZoomSize(a4)
  1767.         move.w    #11,BillZoomSize+2(a4)
  1768.  
  1769.         lea    DefPubScrName(pc),a0        ; Init default public screen list
  1770.         lea    PubScreenName(a4),a1
  1771.         bsr.s    GoStrCpy
  1772.         lea    DefSystemComm(pc),a0        ; Init default system command
  1773.         lea    SystemComm(a4),a1
  1774.         bsr.s    GoStrCpy
  1775.         lea    DefLogFileName(pc),a0        ; Init default LogFile name
  1776.         lea    LogFileName(a4),a1
  1777.         bsr.s    GoStrCpy
  1778.         lea    DefPrefsFName(pc),a0        ; Init default Prefs filename
  1779.         lea    PrefsFileName(a4),a1
  1780. GoStrCpy    bra    StrCpy
  1781. DefPubScrName    dc.b    "TERM",0
  1782. DefLogFileName    dc.b    "S:KCXLOGFILE",0
  1783. DefPrefsFName    dc.b    "KCX.PREFS",0
  1784.         EVEN
  1785.  
  1786.  
  1787.  
  1788. **********************************************************************
  1789. *               Copy default hotkeys to "user" buffers               *
  1790. **********************************************************************
  1791. MakeHotKeys    lea    DefaultHotKeys,a2
  1792.         lea    HotKeyGadStat,a3
  1793.         move.w    #HOTKEYNUM-1,d7
  1794. .Loop        move.l    (a2)+,a0
  1795.         move.l    (a3)+,a1
  1796.         add.l    a4,a1
  1797.         bsr    StrCpy
  1798.         dbf    d7,.Loop
  1799.         rts
  1800.  
  1801.  
  1802.  
  1803. **********************************************************************
  1804. *                      Get the given tooltypes                       *
  1805. **********************************************************************
  1806. GetToolTypes    tst.l    MyToolTypes
  1807.         bne.s    GoOnToolTypes
  1808.         rts
  1809.  
  1810. GetToolSub1    move.l    MyToolTypes,a0
  1811.         RELLIB    FindToolType,_IconBase
  1812.         move.l    d0,d1
  1813.         rts
  1814.  
  1815. GetToolSub2    move.l    a0,d2
  1816.         RELLIB    StrToLong,_DOSBase
  1817.         tst.l    d0
  1818.         rts
  1819.  
  1820. GoOnToolTypes    lea    ToolPriStr(pc),a1        ; Change Tool-Pri ?
  1821.         bsr.s    GetToolSub1
  1822.         beq.s    .NoToolPri            ; No -> go on
  1823.         lea    ToolPri(a4),a0
  1824.         bsr.s    GetToolSub2
  1825.         bge.s    .NoToolPri
  1826.         clr.l    ToolPri(a4)
  1827. .NoToolPri    lea    HandlerPriStr(pc),a1
  1828.         bsr.s    GetToolSub1
  1829.         beq.s    .NoHandlerPri
  1830.         lea    HandlerPri(a4),a0
  1831.         bsr.s    GetToolSub2
  1832.         bge.s    .NoHandlerPri
  1833.         cmp.l    #51,HandlerPri(a4)
  1834.         bge.s    .NoHandlerPri
  1835.         move.l    #55,HandlerPri(a4)
  1836. .NoHandlerPri    lea    PriStr(pc),a1            ; Change broker pri ?
  1837.         bsr.s    GetToolSub1
  1838.         beq.s    .NoCxPri            ; No -> go on
  1839.         lea    CxPri(a4),a0
  1840.         bsr.s    GetToolSub2
  1841.         bge.s    .NoCxPri
  1842.         clr.l    CxPri(a4)
  1843. .NoCxPri    lea    PortNameStr(pc),a1
  1844.         bsr.s    GetToolSub1
  1845.         beq.s    .NoPortName
  1846.         move.l    d0,a0
  1847.         lea    ARexxPortName(pc),a1
  1848.         moveq    #15,d7                ; Copy only 16 Chars
  1849.         bsr    StrNCpy
  1850. .NoPortName    lea    KeyStr(pc),a1
  1851.         bsr    GetToolSub1
  1852.         beq.s    .NoPopKey            ; Nope -> go on
  1853.         move.l    d0,a0
  1854.         lea    ToolPopUpKey(a4),a1        ; Copy PopUpKey
  1855.         bsr    StrCpy
  1856. .NoPopKey    lea    PopUpStr(pc),a1
  1857.         bsr    GetToolSub1
  1858.         beq.s    .DoNotPopUp
  1859.         move.l    d0,a0                ; Do we have a NO flag
  1860.         lea    NoString(pc),a1
  1861.         DOLIB    MatchToolValue
  1862.         tst.l    d0
  1863.         beq.s    .DoNotPopUp
  1864.         clr.b    DoPopUp(a4)            ; Let the window pop up
  1865. .DoNotPopUp    lea    IconStr(pc),a1            ; No icon ?
  1866.         bsr    GetToolSub1
  1867.         beq.s    .NoAppIcon
  1868.         clr.b    DispAppIcon(a4)
  1869. .NoAppIcon    lea    MenuStr(pc),a1            ; No menu ???
  1870.         bsr    GetToolSub1
  1871.         beq.s    .NoAppMenu
  1872.         clr.b    DispAppMenu(a4)
  1873. .NoAppMenu    lea    IconXStr(pc),a1            ; Icon X-Position ?
  1874.         bsr    GetToolSub1
  1875.         beq.s    .NoIconX
  1876.         lea    IconXPos,a0
  1877.         bsr    GetToolSub2
  1878. .NoIconX    lea    IconYStr(pc),a1            ; Icon Y-Position ?
  1879.         bsr    GetToolSub1
  1880.         beq.s    .NoIconY
  1881.         lea    IconYPos,a0
  1882.         bsr    GetToolSub2
  1883. .NoIconY    lea    NoReqStr(pc),a1            ; Don`t show requester ?
  1884.         bsr    GetToolSub1
  1885.         beq.s    .NoReq
  1886.         SF    CheckQuit(a4)
  1887. .NoReq        lea    PrefsStr(pc),a1            ; Alternative Prefs-File ?
  1888.         bsr    GetToolSub1
  1889.         beq.s    .NoPrefs
  1890.         tst.b    FirstPrefs(a4)
  1891.         bne.s    .NoPrefs
  1892.         move.l    d0,a0
  1893.         lea    PrefsFileName(a4),a1
  1894.         bsr    StrCpy
  1895.         ST    HadHardPrefs(a4)
  1896. .NoPrefs    lea    PrefsPathStr(pc),a1        ; New path to Prefs-Prg ?
  1897.         bsr    GetToolSub1
  1898.         beq.s    .NoPrefsPath
  1899.         move.l    d0,a0
  1900.         lea    PrefsPath(a4),a1
  1901.         bsr    StrCpy
  1902. .NoPrefsPath    lea    PrintPathStr(pc),a1        ; New path to printer ?
  1903.         bsr    GetToolSub1
  1904.         beq.s    .NoPrintPath
  1905.         move.l    d0,a0
  1906.         lea    PrintPath(a4),a1
  1907.         bsr    StrCpy
  1908. .NoPrintPath    rts
  1909. **********************************************************************
  1910. *                       Parse the command line                       *
  1911. **********************************************************************
  1912. GetCommandLine    move.l    #((HELP_ARG+1)*4),d0        ; Get buffer for parsed arguments
  1913.         move.l    #MEMF_CLEAR,d1
  1914.         CALLSYS    AllocVec
  1915.         move.l    d0,Args
  1916.         moveq    #0,d7
  1917.         move.l    #MEMORY_ERR,ErrorBack(a4)    ; Set Errornumber
  1918.         tst.l    d0
  1919.         beq    .HelpDone
  1920.         move.l    #CLITemplate,d1            ; Parse commandline
  1921.         move.l    Args(pc),d2
  1922.         moveq    #0,d3
  1923.         RELLIB    ReadArgs,_DOSBase
  1924.         move.l    #NO_ERR,ErrorBack(a4)        ; Set errornumber
  1925.         move.l    d0,MyRDArgs
  1926.         beq    .Error
  1927.  
  1928.         move.l    Args(pc),a5            ; Now check args
  1929.  
  1930.         move.l    (CXPRI_ARG*4)(a5),d0        ; Get Priority for broker ?
  1931.         beq.s    .NoCxPri
  1932.         move.l    d0,a0
  1933.         move.l    (a0),CxPri(a4)
  1934. .NoCxPri    move.l    (CXKEY_ARG*4)(a5),d0        ; New PopKey ???
  1935.         beq.s    .NoCxKey
  1936.         move.l    d0,a0
  1937.         lea    ToolPopUpKey(a4),a1
  1938.         bsr    StrCpy
  1939. .NoCxKey    move.l    (CXPOP_ARG*4)(a5),d0        ; Do popup ???
  1940.         beq.s    .CxPopUp
  1941.         move.l    d0,a0
  1942.         lea    NoString(pc),a1
  1943.         moveq    #-1,d7
  1944.         bsr    StrCmp
  1945.         tst.l    d0
  1946.         bne.s    .CxPopUp
  1947.         clr.b    DoPopUp(a4)            ; Clear flag
  1948. .CxPopUp    move.l    (PORT_ARG*4)(a5),d0        ; New Portname ???
  1949.         beq.s    .NoPortName
  1950.         move.l    d0,a0
  1951.         lea    ARexxPortName(pc),a1
  1952.         moveq    #15,d7                ; Only 16 chars allowed
  1953.         bsr    StrNCpy
  1954. .NoPortName    move.l    (PRGPRI_ARG*4)(a5),d0        ; New ToolPri(a4) ???
  1955.         beq.s    .NoToolPri
  1956.         move.l    d0,a0
  1957.         move.l    (a0),ToolPri(a4)
  1958. .NoToolPri    move.l    (HANDPRI_ARG*4)(a5),d0        ; New Handler priority ?
  1959.         beq.s    .NoHandlerPri
  1960.         move.l    d0,a0
  1961.         move.l    (a0),d0
  1962.         cmp.l    #51,d0
  1963.         blt.s    .NoHandlerPri
  1964.         move.l    d0,HandlerPri(a4)
  1965. .NoHandlerPri    tst.l    (ICON_ARG*4)(a5)        ; Display Icon ???
  1966.         beq.s    .Icon
  1967.         clr.b    DispAppIcon(a4)
  1968. .Icon        tst.l    (MENU_ARG*4)(a5)        ; Attach menu ???
  1969.         beq.s    .Menu
  1970.         clr.b    DispAppMenu(a4)
  1971. .Menu        move.l    (PREFS_ARG*4)(a5),d0        ; Alternative Prefs-File ?
  1972.         beq.s    .NoPrefs
  1973.         move.l    d0,a0
  1974.         lea    PrefsFileName(a4),a1
  1975.         bsr    StrCpy
  1976.         ST    HadHardPrefs(a4)
  1977. .NoPrefs    move.l    (PREFSPATH_ARG*4)(a5),d0    ; New Prefs path ?
  1978.         beq.s    .NoPrefsPath
  1979.         move.l    d0,a0
  1980.         lea    PrefsPath(a4),a1
  1981.         bsr    StrCpy
  1982. .NoPrefsPath    move.l    (PRINTPATH_ARG*4)(a5),d0    ; New Printer path ?
  1983.         beq.s    .NoPrinterPath
  1984.         move.l    d0,a0
  1985.         lea    PrintPath(a4),a1
  1986.         bsr    StrCpy
  1987. .NoPrinterPath    move.l    (ICONX_ARG*4)(a5),d0        ; Icon X-Position ?
  1988.         beq.s    .NoIconX
  1989.         move.l    d0,a0
  1990.         move.l    (a0),IconXPos
  1991. .NoIconX    move.l    (ICONY_ARG*4)(a5),d0        ; Icon Y-Position ?
  1992.         beq.s    .NoIconY
  1993.         move.l    d0,a0
  1994.         move.l    (a0),IconYPos
  1995. .NoIconY    tst.l    (NOREQ_ARG*4)(a5)        ; Disable Quit-Requester ?
  1996.         beq.s    .NoQuit
  1997.         SF    CheckQuit(a4)
  1998. .NoQuit        tst.l    (HELP_ARG*4)(a5)        ; Display Help ???
  1999.         beq.s    .NoCommand
  2000.         RELLIB    Output,_DOSBase
  2001.         move.l    d0,d1
  2002.         LOCLEA    CliHelpPage,a0
  2003.         move.l    a0,d2
  2004.         DOLIB    FPuts
  2005.         moveq    #2,d7
  2006.         move.l    #NO_ERR,ErrorBack(a4)
  2007.         bra.s    .HelpDone
  2008. .NoCommand    moveq    #1,d7
  2009.         bra.s    .HelpDone
  2010. .Error        DOLIB    IoErr                ; On error get code
  2011.         move.l    d0,d1                ; ... and display the message
  2012.         LOCLEA    CommandHeader,a0
  2013.         move.l    a0,d2
  2014.         DOLIB    PrintFault
  2015.         moveq    #0,d7
  2016. .HelpDone    move.l    MyRDArgs(pc),d1
  2017.         beq.s    .NoRDArgs
  2018.         RELLIB    FreeArgs,_DOSBase
  2019. .NoRDArgs    move.l    Args(pc),d0
  2020.         beq.s    .NoArgs
  2021.         move.l    d0,a1            ; Free Vector-Table
  2022.         CALLSYS    FreeVec
  2023. .NoArgs        rts
  2024. **********************************************************************
  2025. *             Definition for the template and ToolTypes              *
  2026. **********************************************************************
  2027. NoString    dc.b    "NO",0
  2028. PriStr        dc.b    "CX_PRIORITY",0
  2029. KeyStr        dc.b    "CX_POPKEY",0
  2030. PopUpStr    dc.b    "CX_POPUP",0
  2031. PortNameStr    dc.b    "PORTNAME",0
  2032. ToolPriStr    dc.b    "TOOLPRI",0
  2033. HandlerPriStr    dc.b    "HANDLERPRI",0
  2034. IconStr        dc.b    "NOICON",0
  2035. MenuStr        dc.b    "NOMENU",0
  2036. PrefsStr    dc.b    "SETTINGS",0
  2037. PrefsPathStr    dc.b    "PREFSPATH",0
  2038. PrintPathStr    dc.b    "PRINTERPATH",0
  2039. IconXStr    dc.b    "ICONX",0
  2040. IconYStr    dc.b    "ICONY",0
  2041. NoReqStr    dc.b    "NOREQ",0
  2042. CLITemplate    dc.b    "CP=CX_PRIORITY/N,CK=CX_POPKEY/K,CU=CX_POPUP/K,P=PORTNAME/K,T=TOOLPRI/N,H=HANDLERPRI/N,N=NOICON/S,M=NOMENU/S,S=SETTINGS/K,E=PREFSPATH/K,R=PRINTERPATH/R,X=ICONX/N,Y=ICONY/N,NOREQ/S,HELP/S",0
  2043.         EVEN
  2044. CXPRI_ARG    EQU    0
  2045. CXKEY_ARG    EQU    1
  2046. CXPOP_ARG    EQU    2
  2047. PORT_ARG    EQU    3
  2048. PRGPRI_ARG    EQU    4
  2049. HANDPRI_ARG    EQU    5
  2050. ICON_ARG    EQU    6
  2051. MENU_ARG    EQU    7
  2052. PREFS_ARG    EQU    8
  2053. PREFSPATH_ARG    EQU    9
  2054. PRINTPATH_ARG    EQU    10
  2055. ICONX_ARG    EQU    11
  2056. ICONY_ARG    EQU    12
  2057. NOREQ_ARG    EQU    13
  2058. HELP_ARG    EQU    14
  2059.  
  2060.  
  2061.  
  2062.  
  2063. **********************************************************************
  2064. *   This routine checks for existing drives and initializes stuff    *
  2065. *                       for each drive present                       *
  2066. **********************************************************************
  2067. InitDrives    move.l    #TRACKPORT_ERR,ErrorBack(a4)    ; Create a port for trackdisk device
  2068.         CALLSYS    CreateMsgPort
  2069.         move.l    d0,TrackPort(a4)
  2070.         beq    .Error
  2071.         move.l    d0,a0
  2072.         clr.l    LN_NAME(a0)
  2073.         clr.b    LN_PRI(a0)
  2074.  
  2075.         clr.w    NumDrives(a4)
  2076.         lea    DriveNames(pc),a0
  2077.         lea    DriveList(a4),a2
  2078.         lea    DriveRequests(a4),a3
  2079.         lea    DriveChange(a4),a5
  2080.         moveq    #0,d7                ; Drive number
  2081. .LoopDrives    movem.l    a0-a3,-(sp)            ; Create an IORequest for the drive in question
  2082.         move.l    TrackPort(a4),a0
  2083.         move.l    #IOTD_SIZE,d0
  2084.         CALLSYS    CreateIORequest
  2085.         movem.l    (sp)+,a0-a3
  2086.         tst.l    d0
  2087.         beq.s    .Error
  2088.         move.l    d0,(a3)
  2089.         movem.l    a0-a3,-(sp)
  2090.         lea    TrackName(pc),a0        ; Try to open device for that drive
  2091.         move.l    d0,a1
  2092.         move.l    d7,d0
  2093.         move.l    #TDF_ALLOW_NON_3_5,d1
  2094.         DOLIB    OpenDevice
  2095.         movem.l    (sp)+,a0-a3
  2096.         tst.l    d0
  2097.         beq.s    .GotDrive
  2098.         move.l    a0,-(sp)
  2099.         move.l    (a3),a0                ; If not found -> delete IORequest
  2100.         DOLIB    DeleteIORequest
  2101.         move.l    (sp)+,a0
  2102.         clr.l    (a3)
  2103.         bra.s    .NextDrive
  2104. .GotDrive    move.l    (a0),(a2)+            ; Copy pointer to name to CycleGadget`s list
  2105.         move.l    d7,d0                ; Make gadget available
  2106.         mulu    #28,d0
  2107.         lea    WatchGads,a1
  2108.         clr.l    4(a1,d0)
  2109.         lea    DriveThere(a4),a1        ; Store, which drivenumber is within this slot
  2110.         move.w    NumDrives(a4),d0
  2111.         move.b    d7,0(a1,d0)
  2112.         move.l    (a3),a1
  2113.         move.w    #TD_CHANGENUM,IO_COMMAND(a1)    ; Get actual number of diskchanges for that drive
  2114.         clr.b    IO_FLAGS(a1)
  2115.         movem.l    a0-a3,-(sp)
  2116.         DOLIB    DoIO
  2117.         movem.l    (sp)+,a0-a3
  2118.         move.l    IO_ACTUAL(a1),(a5)        ; Store number within our buffer
  2119.         addq.l    #4,a3
  2120.         addq.l    #4,a5
  2121.         addq.w    #1,NumDrives(a4)        ; We had another one -> increase number of drives
  2122. .NextDrive    addq.l    #4,a0
  2123.         addq.l    #1,d7
  2124.         cmp.l    #4,d7
  2125.         bne    .LoopDrives
  2126. .Error        rts
  2127. **********************************************************************
  2128. *       These are the names for external drives to be checked        *
  2129. **********************************************************************
  2130. DriveNames    dc.l    .Txt1,.Txt2,.Txt3,.Txt4
  2131. .Txt1    dc.b    "DF0:",0
  2132. .Txt2    dc.b    "DF1:",0
  2133. .Txt3    dc.b    "DF2:",0
  2134. .Txt4    dc.b    "DF3:",0
  2135. TrackName    dc.b    "trackdisk.device",0
  2136.         EVEN
  2137.  
  2138.  
  2139.  
  2140. **********************************************************************
  2141. *            Remove occupied resources for drive checking            *
  2142. **********************************************************************
  2143. RemoveDrives    lea    DriveRequests(a4),a3        ; Close devices for all IORequests
  2144.         moveq    #3,d7
  2145. .FreeRequests    tst.l    (a3)
  2146.         beq.s    .NoReq
  2147.         move.l    (a3),a1
  2148.         tst.l    IO_DEVICE(a1)
  2149.         beq.s    .NoDevice
  2150.         CALLSYS    CloseDevice
  2151. .NoDevice    move.l    (a3),a0                ; And remove Request itself
  2152.         CALLSYS    DeleteIORequest
  2153. .NoReq        clr.l    (a3)
  2154.         addq.l    #4,a3
  2155.         dbf    d7,.FreeRequests
  2156.  
  2157.         tst.l    TrackPort(a4)            ; Shut down MsgPort
  2158.         beq.s    .NoPort
  2159.         move.l    TrackPort(a4),a0
  2160.         CALLSYS    DeleteMsgPort
  2161. .NoPort        clr.l    TrackPort(a4)
  2162.         rts
  2163.  
  2164.  
  2165.  
  2166.  
  2167. **********************************************************************
  2168. *                Try to read in the default PrefsFile                *
  2169. **********************************************************************
  2170. LoadPrefs    move.l    #NOIFF_ERR,ErrorBack(a4)
  2171.         RELLIB    AllocIFF,_IFFParseBase
  2172.         move.l    d0,MyIFFHandle(a4)
  2173.         tst.l    d0
  2174.         beq    .LoadError1
  2175.  
  2176.         lea    PrefsFileName(a4),a0
  2177.         move.l    a0,d1            ; Try to open user-defined file
  2178.         move.l    d1,BackErrArg(a4)
  2179.         move.l    #MODE_OLDFILE,d2
  2180.         RELLIB    Open,_DOSBase
  2181.         tst.l    d0
  2182.         bne.s    .GotPrefFile
  2183.         tst.b    FirstPrefs(a4)
  2184.         bne    .DosLoadError
  2185.         tst.b    HadHardPrefs(a4)
  2186.         bne    .EndLoad
  2187.  
  2188.         lea    DirPrefsName,a0
  2189.         lea    PrefsFileName(a4),a1
  2190.         bsr    StrCpy
  2191.  
  2192.         move.l    #DirPrefsName,d1    ; Try to open file in current directory
  2193.         move.l    d1,BackErrArg(a4)
  2194.         move.l    #MODE_OLDFILE,d2
  2195.         DOLIB    Open
  2196.         tst.l    d0
  2197.         bne.s    .GotPrefFile
  2198.  
  2199.         lea    EnvPrefsName,a0
  2200.         lea    PrefsFileName(a4),a1
  2201.         bsr    StrCpy
  2202.  
  2203.         move.l    #EnvPrefsName,d1    ; Try to open File within env:kcx/
  2204.         move.l    d1,BackErrArg(a4)
  2205.         move.l    #MODE_OLDFILE,d2
  2206.         DOLIB    Open
  2207.         tst.l    d0
  2208.         beq    .EndLoad
  2209.  
  2210. .GotPrefFile    move.l    MyIFFHandle(a4),a0
  2211.         move.l    d0,iff_Stream(a0)
  2212.  
  2213.         RELLIB    InitIFFasDOS,_IFFParseBase
  2214.  
  2215.         move.l    MyIFFHandle(a4),a0
  2216.         move.l    #IFFF_READ,d0
  2217.         DOLIB    OpenIFF
  2218.         tst.l    d0
  2219.         bne    .LoadError
  2220.  
  2221.         move.l    MyIFFHandle(a4),a0    ; Find version ID
  2222.         move.l    #'KCXM',d0
  2223.         move.l    #'VERS',d1
  2224.         DOLIB    PropChunk
  2225.         tst.l    d0
  2226.         bne    .LoadError
  2227.  
  2228.         move.l    MyIFFHandle(a4),a0        ; Get to 'KCXM' -> 'PREF'
  2229.         move.l    #'KCXM',d0
  2230.         move.l    #'PREF',d1
  2231.         DOLIB    StopChunk
  2232.         tst.l    d0
  2233.         bne    .LoadError
  2234.  
  2235.         move.l    MyIFFHandle(a4),a0        ; Scan to chunk
  2236.         move.l    #IFFPARSE_SCAN,d0
  2237.         DOLIB    ParseIFF
  2238.         tst.l    d0
  2239.         bne    .LoadError
  2240.  
  2241. .ScannedFile    move.l    MyIFFHandle(a4),a0        ; Did we have a VERSion chunk ?
  2242.         move.l    #'KCXM',d0
  2243.         move.l    #'VERS',d1
  2244.         DOLIB    FindProp
  2245.         tst.l    d0
  2246.         beq.s    .PrefsError
  2247.         move.l    d0,a0                ; Correct version ?
  2248.         move.l    spr_Data(a0),a0
  2249.         lea    VersChunk,a1
  2250.         move.w    (a0)+,d0
  2251.         move.w    (a0),d1
  2252.         cmp.w    (a1),d0
  2253.         bne.s    .PrefsError
  2254.         cmp.w    2(a1),d1
  2255.         beq.s    .IsPrefs
  2256. .PrefsError    move.l    #PREFS_ERR,ErrorBack(a4)
  2257.         lea    VersionStr,a0
  2258.         move.l    a0,BackErrArg(a4)
  2259.         bsr    DisplayError
  2260.         bra    .LoadError
  2261.  
  2262. .IsPrefs    move.l    MyIFFHandle(a4),a0        ; Read Bool qualifiers
  2263.         lea    BOOLQUALSTART(a4),a1
  2264.         move.l    #FLAGSET,d0
  2265.         DOLIB    ReadChunkBytes
  2266.         cmp.l    #FLAGSET,d0
  2267.         bne    .LoadError
  2268.  
  2269.         move.l    MyIFFHandle(a4),a0        ; Read Long qualifiers
  2270.         lea    LONGQUALSTART(a4),a1
  2271.         move.l    #LONGQUAL,d0
  2272.         DOLIB    ReadChunkBytes
  2273.         cmp.l    #LONGQUAL,d0
  2274.         bne    .LoadError
  2275.  
  2276.         lea    HotKeyGadStat,a3        ; Read HotKey definitions
  2277.         move.l    #HOTKEYNUM-1,d7
  2278. .LoopHKeys    move.l    MyIFFHandle(a4),a0
  2279.         move.l    (a3)+,a1
  2280.         add.l    a4,a1
  2281.         move.l    #40,d0
  2282.         DOLIB    ReadChunkBytes
  2283.         cmp.l    #40,d0
  2284.         bne    .LoadError
  2285.         dbf    d7,.LoopHKeys
  2286.  
  2287.         move.l    MyIFFHandle(a4),a0        ; Read User-Shell command
  2288.         lea    SystemComm(a4),a1
  2289.         move.l    #256,d0
  2290.         DOLIB    ReadChunkBytes
  2291.         cmp.l    #256,d0
  2292.         bne    .LoadError
  2293.  
  2294.         move.l    MyIFFHandle(a4),a0        ; Read Logfilename
  2295.         lea    LogFileName(a4),a1
  2296.         move.l    #300,d0
  2297.         DOLIB    ReadChunkBytes
  2298.         cmp.l    #300,d0
  2299.         bne    .LoadError
  2300.  
  2301.         move.l    MyIFFHandle(a4),a0        ; Read Public Screen list
  2302.         lea    PubScreenName(a4),a1
  2303.         move.l    #256,d0
  2304.         DOLIB    ReadChunkBytes
  2305.         cmp.l    #256,d0
  2306.         bne    .LoadError
  2307.  
  2308.         move.l    MyIFFHandle(a4),a0        ; Read FKeys
  2309.         lea    FKeys(a4),a1
  2310.         move.l    #(MAXFKEYWIDTH+2)*10*4,d0
  2311.         DOLIB    ReadChunkBytes
  2312.         cmp.l    #(MAXFKEYWIDTH+2)*10*4,d0
  2313.         bne    .LoadError
  2314.  
  2315.         move.l    MyIFFHandle(a4),a0        ; Read sample name
  2316.         lea    AlSampleName(a4),a1
  2317.         move.l    #256,d0
  2318.         DOLIB    ReadChunkBytes
  2319.         cmp.l    #256,d0
  2320.         bne    .LoadError
  2321.  
  2322.         move.l    MyIFFHandle(a4),a0        ; Read format drive name
  2323.         lea    FormatDriveName(a4),a1
  2324.         move.l    #32,d0
  2325.         DOLIB    ReadChunkBytes
  2326.         cmp.l    #32,d0
  2327.         bne    .LoadError
  2328.  
  2329.         move.l    MyIFFHandle(a4),a0        ; Read window positions
  2330.         lea    MainWinLeft(a4),a1
  2331.         move.l    #WINPOSLEN,d0
  2332.         DOLIB    ReadChunkBytes
  2333.         cmp.l    #WINPOSLEN,d0
  2334.         bne    .LoadError
  2335.  
  2336.         clr.w    NumLockEntries(a4)
  2337.         clr.l    GlobalTagAdr(a4)
  2338.         lea    WindowBase(a4),a0        ; Read in window names
  2339.         lea    NumWindows(a4),a1
  2340.         move.l    #lw_Name,d6
  2341.         move.l    #lw_SIZEOF,d5
  2342.         move.l    #82,d4
  2343.         bsr.s    .ReadNameChunk
  2344.         tst.l    d0
  2345.         bne    .LoadError
  2346.         lea    TaskWinBase(a4),a0        ; Read task names
  2347.         lea    NumTaskWins(a4),a1
  2348.         move.l    #lw_Name,d6
  2349.         move.l    #lw_SIZEOF,d5
  2350.         move.l    #82,d4
  2351.         bsr.s    .ReadNameChunk
  2352.         tst.l    d0
  2353.         bne    .LoadError
  2354.         lea    TagScrsTasks(a4),a0        ; Read tag screen task names
  2355.         lea    TagScrNum(a4),a1
  2356.         move.l    #tagscr_Name,d6
  2357.         move.l    #tagscr_SIZEOF,d5
  2358.         move.l    #tagscr_SIZEOF-LN_SIZE,d4
  2359.         bsr.s    .ReadNameChunk
  2360.         tst.l    d0
  2361.         bne    .LoadError
  2362.         lea    TagScrsTasks(a4),a2        ; Search for Global entry
  2363.         TSTLIST    a2
  2364.         beq.s    .GotEnd
  2365.         move.l    LH_HEAD(a2),a2
  2366. .FindGlobal    move.l    a2,d0
  2367.         beq.s    .GotEnd
  2368.         tst.b    tagscr_Type(a2)
  2369.         bne.s    .GotGlobal
  2370.         SUCC    a2,a2
  2371.         bra.s    .FindGlobal
  2372. .GotGlobal    move.l    a2,GlobalTagAdr(a4)
  2373.         LOCLEA    GlobalTagName,a0
  2374.         lea    tagscr_Name(a2),a1
  2375.         bsr    StrCpy
  2376. .GotEnd        moveq    #0,d0
  2377.         bra    .LoadError
  2378.  
  2379. .ReadNameChunk    move.l    a0,a3                ; Copy pointer to other register
  2380.         move.l    a1,a2
  2381.         NEWLIST    a0
  2382.         move.l    MyIFFHandle(a4),a0
  2383.         moveq    #2,d0
  2384.         RELLIB    ReadChunkBytes,_IFFParseBase
  2385.         cmp.l    #2,d0
  2386.         bne.s    .NameLoadError
  2387.         move.w    (a2),d7                ; Get number of entries
  2388.         subq.w    #1,d7
  2389.         blt.s    .EndReadChunk
  2390. .LoopWins    move.l    d5,d0                ; Read in window names
  2391.         move.l    #MEMF_CLEAR,d1
  2392.         CALLSYS    AllocVec
  2393.         tst.l    d0
  2394.         bne.s    .GotEntry
  2395.         move.l    #MEMORY_ERR,ErrorBack(a4)
  2396.         bsr    DisplayError
  2397.         moveq    #0,d0
  2398.         bra.s    .NameLoadError
  2399. .GotEntry    move.l    a3,a0                ; Add entry
  2400.         move.l    d0,a1
  2401.         move.l    d0,a2
  2402.         ADDTAIL
  2403.         move.l    MyIFFHandle(a4),a0
  2404.         lea    0(a2,d6),a1
  2405.         move.l    a1,LN_NAME(a2)
  2406.         move.l    d4,d0
  2407.         RELLIB    ReadChunkBytes,_IFFParseBase
  2408.         tst.l    d0
  2409.         bne.s    .GotName
  2410.         move.l    a2,a1
  2411.         REMOVE
  2412.         move.l    a2,a1
  2413.         CALLSYS    FreeVec
  2414.         bra.s    .EndLoad
  2415. .GotName    cmp.l    d4,d0
  2416.         bne.s    .NameLoadError
  2417.         dbf    d7,.LoopWins
  2418. .EndReadChunk    moveq    #0,d0
  2419. .NameLoadError    rts
  2420.  
  2421. .LoadError    tst.l    d0                ; Handle errors ...
  2422.         beq.s    .EndLoad
  2423.         neg.l    d0
  2424.         add.l    #400,d0
  2425.         move.l    d0,ErrorBack(a4)
  2426. .LoadError1    bsr    DisplayError
  2427.         bra.s    .EndLoad
  2428. .DosLoadError    RELLIB    IoErr,_DOSBase
  2429.         move.l    d0,ErrorBack(a4)
  2430.         bsr    DisplayError
  2431. .EndLoad    tst.l    MyIFFHandle(a4)            ; and close resources
  2432.         beq.s    .NoHandle
  2433.         move.l    MyIFFHandle(a4),a0
  2434.         RELLIB    CloseIFF,_IFFParseBase
  2435.         move.l    MyIFFHandle(a4),a0
  2436.         tst.l    iff_Stream(a0)
  2437.         beq.s    .NoStream
  2438.         move.l    iff_Stream(a0),d1
  2439.         RELLIB    Close,_DOSBase
  2440. .NoStream    move.l    MyIFFHandle(a4),a0
  2441.         RELLIB    FreeIFF,_IFFParseBase
  2442.  
  2443. .NoHandle    move.l    SavedPage(a4),d0
  2444.         move.l    d0,PageNum(a4)
  2445.  
  2446.         bsr    InitAlarmSmp
  2447.         move.b    #1,FirstPrefs(a4)
  2448.         move.b    ShowClock(a4),d0
  2449.         move.b    d0,OldClockState(a4)
  2450.         rts
  2451. **********************************************************************
  2452. *                Chunkdefinitions for the Prefs file                 *
  2453. **********************************************************************
  2454. VersChunk    dc.w    VERNUM,REVNUM
  2455. VersChunkSize    EQU    *-VersChunk
  2456.  
  2457.  
  2458.  
  2459.  
  2460. **********************************************************************
  2461. *  This routine initializes the process to handle all check events   *
  2462. **********************************************************************
  2463. InitChecker    CALLSYS    Forbid
  2464.         lea    CheckerTags(pc),a0
  2465.         move.l    a0,d1                ; Start Process with tags
  2466.         RELLIB    CreateNewProc,_DOSBase
  2467.         CALLSYS    Permit
  2468.         tst.l    d0
  2469.         beq.s    .Error
  2470.         move.l    #SIGHANDSHAKE,d0        ; Wait for reply
  2471.         CALLSYS    Wait
  2472. .Error        rts
  2473. **********************************************************************
  2474. *               Tags for new process of checker events               *
  2475. **********************************************************************
  2476. CheckerTags    dc.l    NP_Entry            ; We only supply an entry point
  2477.         dc.l    TimeChecker
  2478.         dc.l    NP_Name                ; Name of process
  2479.         dc.l    CheckerName
  2480.         dc.l    NP_Priority            ; We run at a higher proirity
  2481.         dc.l    10                ; so that we`re quite fast
  2482.         dc.l    NP_StackSize            ; Stack-Size to be used
  2483.         dc.l    6000
  2484.         dc.l    TAG_DONE
  2485.  
  2486.  
  2487.  
  2488.  
  2489. **********************************************************************
  2490. *                     Install the ARexx-Process                      *
  2491. **********************************************************************
  2492. InitRexxProc    CALLSYS    Forbid
  2493.         lea    RexxTags(pc),a0
  2494.         move.l    a0,d1                ; Start Process
  2495.         RELLIB    CreateNewProc,_DOSBase
  2496.         CALLSYS    Permit
  2497.         tst.l    d0
  2498.         beq.s    .Error
  2499.         move.l    #SIGHANDSHAKE,d0        ; Wait for reply
  2500.         CALLSYS    Wait
  2501. .Error        rts
  2502. **********************************************************************
  2503. *                Tags for new process of ARexx events                *
  2504. **********************************************************************
  2505. RexxTags    dc.l    NP_Entry            ; We only supply an entry point
  2506.         dc.l    RexxChecker
  2507.         dc.l    NP_Name                ; Name of process
  2508.         dc.l    RexxName
  2509.         dc.l    NP_Priority            ; We run at a higher proirity
  2510.         dc.l    0                ; so that we`re quite fast
  2511.         dc.l    NP_StackSize            ; Stack-Size to be used
  2512.         dc.l    4096
  2513.         dc.l    TAG_DONE
  2514.  
  2515.  
  2516.  
  2517.  
  2518.  
  2519. **********************************************************************
  2520. *          This is the small process to handle timer events          *
  2521. **********************************************************************
  2522. TimeChecker    movem.l    RegsAll,-(sp)
  2523.  
  2524.         move.l    ZeroBase(pc),a4
  2525.  
  2526.         moveq    #-1,d0                ; Get signal for Events
  2527.         CALLSYS    AllocSignal
  2528.         move.l    d0,EventSigBit(a4)
  2529.         blt    CheckerError
  2530.         moveq    #1,d1
  2531.         lsl.l    d0,d1
  2532.         move.l    d1,EventSigFlag(a4)
  2533.  
  2534.         bsr    InitAudio            ; Init Audio-Stuff
  2535.         tst.l    d0
  2536.         beq    CheckerError
  2537.  
  2538.         bsr    InitHandler            ; Install the InputHandler
  2539.         tst.l    d0
  2540.         beq    CheckerError
  2541.  
  2542.         sub.l    a1,a1
  2543.         DOLIB    FindTask
  2544.         move.l    d0,CheckerProc(a4)
  2545.  
  2546.         move.l    BackTask(a4),a1            ; Signal mother
  2547.         move.l    #SIGHANDSHAKE,d0
  2548.         DOLIB    Signal
  2549.  
  2550. .Loop        move.l    #SIGHANDSHAKE|SIGTIMEREMAKE|SIGBILLWIN,d0        ; for signal to go away
  2551.         or.l    BillSigFlag(a4),d0        ; message from bill window
  2552.         or.l    ClockSigFlag(a4),d0        ; message from clock window
  2553.         or.l    EventSigFlag(a4),d0        ; for input events
  2554.         CALLSYS    Wait
  2555.         move.l    d0,CheckerProcSig(a4)
  2556.  
  2557.         move.l    CheckerProcSig(a4),d0        ; Got signal to cycle ?
  2558.         and.l    EventSigFlag(a4),d0
  2559.         beq.s    .NoEventSig
  2560.  
  2561.         bsr    EventMsgLoop            ; Check for pending "events"
  2562.  
  2563. .NoEventSig    move.l    CheckerProcSig(a4),d0        ; Are we to go away ?
  2564.         and.l    #SIGHANDSHAKE,d0
  2565.         bne    CheckerError            ; Yep -> do so
  2566.  
  2567.         move.l    CheckerProcSig(a4),d0        ; Did it come from the
  2568.         and.l    BillSigFlag(a4),d0        ; Bill window ?
  2569.         beq.s    .NoBillSig
  2570.         bsr    CheckBillWindow
  2571.  
  2572. .NoBillSig    move.l    CheckerProcSig(a4),d0        ; Only remake time display ?
  2573.         and.l    #SIGTIMEREMAKE,d0
  2574.         beq.s    .NoTimeRemake
  2575.         bsr    SetTime                ; Yep -> do so
  2576.         bsr    RemakeCosts            ; Also redisplay billstuff
  2577.  
  2578. .NoTimeRemake    move.l    CheckerProcSig(a4),d0        ; Pop up bill window ?
  2579.         and.l    #SIGBILLWIN,d0
  2580.         beq.s    .NoBillOpenUp
  2581.         tst.l    BillHandle(a4)            ; Window already open ?
  2582.         bne.s    .CloseBill            ; yep -> close it
  2583.         bsr    OpenBillWin
  2584.         bra.s    .NoBillOpenUp
  2585. .CloseBill    bsr    CloseBillWin
  2586.  
  2587. .NoBillOpenUp    move.l    CheckerProcSig(a4),d0        ; Message from clock window ?
  2588.         and.l    ClockSigFlag(a4),d0
  2589.         beq.s    .NoClockMsg
  2590.  
  2591. .LoopClockMsg    move.l    ClockHandle(a4),a0
  2592.         move.l    wd_UserPort(a0),a0
  2593.         CALLSYS    GetMsg
  2594.         tst.l    d0
  2595.         beq.s    .NoClockMsg
  2596.  
  2597.         move.l    d0,a1
  2598.         move.l    im_Class(a1),d7
  2599.  
  2600.         DOLIB    ReplyMsg
  2601.  
  2602.         cmp.l    #IDCMP_CLOSEWINDOW,d7        ; Clock window closed ?
  2603.         bne.s    .NoClockClose
  2604.         bsr    CloseClockWin
  2605.         clr.b    ClockWin(a4)
  2606.         CALLSYS    Forbid
  2607.         moveq    #0,d0
  2608.         move.l    #GD_DisplayWin,d1
  2609.         lea    ClockDefGads(a4),a0
  2610.         move.l    ClockDefHandle(a4),a1
  2611.         RELLIB    SetCheckBox,_KCXBase
  2612.         CALLSYS    Permit
  2613.         bra.s    .NoClockMsg
  2614.  
  2615. .NoClockClose    cmp.l    #IDCMP_CHANGEWINDOW,d7        ; Window moved ?
  2616.         bne.s    .LoopClockMsg
  2617.         move.l    ClockHandle(a4),a0
  2618.         lea    ClockWinLeft(a4),a1
  2619.         bsr    StoreWinPos
  2620.         bra    .LoopClockMsg
  2621. .NoClockMsg    bra    .Loop
  2622.  
  2623. CheckerError    bsr    RemoveHandler            ; Remove Handler
  2624.         bsr    RemoveAudio            ; Remove Audio-Stuff
  2625.         bsr    CloseBillWin            ; Close the billwindow
  2626.  
  2627.         tst.l    EventSigBit(a4)            ; Clear SigBit
  2628.         blt.s    .NoEventSig
  2629.         move.l    EventSigBit(a4),d0
  2630.         CALLSYS    FreeSignal
  2631.  
  2632. .NoEventSig    move.l    #-1,EventSigBit(a4)
  2633.         bsr    OnMouse
  2634.         CALLSYS    Forbid
  2635.         bsr    OnScreen
  2636.         CALLSYS    Permit
  2637.         move.l    BackTask(a4),a1            ; Signal mother that we`re fine
  2638.         move.l    #SIGHANDSHAKE,d0
  2639.         CALLSYS    Signal
  2640.         movem.l    (sp)+,RegsAll
  2641.         rts
  2642.  
  2643.  
  2644.  
  2645. **********************************************************************
  2646. *                  Handler for incoming InputEvents                  *
  2647. **********************************************************************
  2648. EventMsgLoop    lea    EventPool(a4),a0        ; Find an event
  2649.         moveq    #MAXEVENTS-1,d7
  2650. .Find        tst.l    LN_NAME(a0)
  2651.         bne.s    .GoOn
  2652.         lea    req_SIZEOF(a0),a0
  2653.         dbf    d7,.Find
  2654.         rts
  2655.  
  2656. .GoOn        move.l    a0,EventMsg(a4)            ; Store pointer to event
  2657.  
  2658.         move.l    EventMsg(a4),a0            ; Activate window ?
  2659.         cmp.l    #REQ_ACTIVATE,LN_NAME(a0)
  2660.         bne    NoActiveEvent
  2661.         bsr    Activate
  2662.         move.l    EventMsg(a4),a0
  2663.         lea    req_IEvent(a0),a0
  2664.         cmp.b    #IECLASS_RAWKEY,ie_Class(a0)
  2665.         bne    EventDone
  2666.         tst.b    MapUmlaut(a4)            ; Map "Umlauts" ?
  2667.         beq    NoUmlaut
  2668.         move.l    EventMsg(a4),a1            ; Check for "Umlauts"
  2669.         lea    req_IEvent(a1),a1
  2670.         move.w    ie_Qualifier(a1),d1        ; Only accept plain and shifted keys
  2671.         and.w    #~(IEQUALIFIER_REPEAT|IEQUALIFIER_NUMERICPAD|IEQUALIFIER_INTERRUPT|IEQUALIFIER_RELATIVEMOUSE|IEQUALIFIER_MULTIBROADCAST),d1
  2672.         move.w    d1,d2
  2673.         and.w    #(IEQUALIFIER_LALT|IEQUALIFIER_RALT|IEQUALIFIER_LCOMMAND|IEQUALIFIER_RCOMMAND),d2
  2674.         bne    NoUmlaut
  2675.         movem.l    d1/a1,-(sp)
  2676.         link    a5,#-20
  2677.         move.l    a1,a0
  2678.         lea    -20(a5),a1
  2679.         clr.b    (a1)
  2680.         move.l    #19,d1
  2681.         sub.l    a2,a2
  2682.         RELLIB    MapRawKey,_KeyMapBase
  2683.         moveq    #0,d0
  2684.         move.b    -20(a5),d0
  2685.         unlk    a5
  2686.         movem.l    (sp)+,d1/a1
  2687. .UmlautOk    lea    UmlautTab(pc),a3        ; Get UmlautTab
  2688.         moveq    #7,d7
  2689. .GetUmlaut    cmp.w    (a3),d0                ; Got "Umlaut" ?
  2690.         beq.s    .GotUmlaut            ; Yep -> go on
  2691.         addq.l    #6,a3
  2692.         dbf    d7,.GetUmlaut
  2693.         bra.s    NoUmlaut            ; No "Umlaut"
  2694. .GotUmlaut    cmp.b    #'ß',d0
  2695.         bne.s    .NoSS
  2696.         move.w    d1,d0
  2697.         and.w    #(IEQUALIFIER_LSHIFT|IEQUALIFIER_RSHIFT),d0
  2698.         bne.s    NoUmlaut
  2699.         bra.s    .NoShift
  2700. .NoSS        tst.w    (a3)                ; Skip shifted ß
  2701.         beq.s    NoUmlaut
  2702.  
  2703. .NoShift    link    a5,#-ie_SIZEOF            ; Get space for one IEs
  2704.         move.b    ie_SubClass(a1),d0        ; Get subclass
  2705.         move.l    ie_EventAddress(a1),d2        ; Address
  2706.  
  2707.         lea    -ie_SIZEOF(a5),a0        ; Create new event -> Clear link to next
  2708.         clr.l    ie_NextEvent(a0)
  2709.         move.b    #IECLASS_RAWKEY,ie_Class(a0)
  2710.         move.b    d0,ie_SubClass(a0)
  2711.         move.w    2(a3),ie_Code(a0)        ; Get first char for "Umlaut"
  2712.         move.w    d1,ie_Qualifier(a0)
  2713.         move.l    d2,ie_EventAddress(a0)
  2714.         LNKLIB    AddIEvents,_CxBase        ; Add events
  2715.         lea    -ie_SIZEOF(a5),a0
  2716.         move.w    4(a3),ie_Code(a0)        ; Get second char for "Umlaut"
  2717.         and.w    #~(IEQUALIFIER_LSHIFT|IEQUALIFIER_RSHIFT),ie_Qualifier(a0)
  2718.         DOLIB    AddIEvents
  2719.         unlk    a5
  2720.         bra.s    HadUmlaut
  2721. NoUmlaut    clr.l    ie_NextEvent(a0)
  2722.         LNKLIB    AddIEvents,_CxBase
  2723. HadUmlaut    tst.b    MouseEver(a4)            ; Blank mouse ?
  2724.         beq.s    .NoMouseOff
  2725.         move.l    EventMsg(a4),a1
  2726.         lea    req_IEvent(a1),a1
  2727.         move.w    ie_Code(a1),d0
  2728.         move.w    ie_Qualifier(a1),d1
  2729.         and.w    #IEQUALIFIER_LCOMMAND,d1
  2730.         beq.s    .NoMouseOff
  2731.         cmp.w    #$4c,d0                ; Check for cursor keys
  2732.         blt.s    .DoOff
  2733.         cmp.w    #$4f,d0
  2734.         bgt.s    .DoOff
  2735.         bra.s    .NoMouseOff
  2736. .DoOff        bsr    OffMouse            ; On key-press allways blank mouse
  2737. .NoMouseOff    bra    EventDone
  2738.  
  2739. NoActiveEvent    move.l    EventMsg(a4),a0
  2740.         cmp.l    #REQ_RAWKEY,LN_NAME(a0)
  2741.         bne    NoKeyEvent
  2742.  
  2743.         tst.b    Disabled(a4)
  2744.         bne.s    .End1
  2745.         tst.b    MouseEver(a4)            ; Blank mouse ?
  2746.         beq.s    .End1
  2747.         move.l    EventMsg(a4),a1
  2748.         lea    req_IEvent(a1),a1
  2749.         move.w    ie_Code(a1),d0
  2750.         move.w    ie_Qualifier(a1),d1
  2751.         and.w    #~(IEQUALIFIER_REPEAT|IEQUALIFIER_NUMERICPAD|IEQUALIFIER_INTERRUPT|IEQUALIFIER_RELATIVEMOUSE|IEQUALIFIER_MULTIBROADCAST),d1
  2752.         bsr    FilterDouble
  2753.         cmp.w    #IEQUALIFIER_LCOMMAND,d1
  2754.         bne.s    .DoOff
  2755.         cmp.w    #$4c,d0                ; Check for cursor keys
  2756.         blt.s    .DoOff
  2757.         cmp.w    #$4f,d0
  2758.         bgt.s    .DoOff
  2759.         bra.s    .End1
  2760. .DoOff        bsr    OffMouse            ; On key-press allways blank mouse
  2761.  
  2762. .End1        tst.b    Disabled(a4)
  2763.         bne    .NoClickYet
  2764.         tst.b    KeyClick(a4)
  2765.         beq    .NoClickYet
  2766.         lea    AudioName(pc),a0        ; Try to open device and
  2767.         moveq    #0,d0                ; allocate a channel
  2768.         move.l    AudioReq(a4),a1
  2769.         move.w    #ADCMD_ALLOCATE,IO_COMMAND(a1)
  2770.         move.b    #ADIOF_NOWAIT,IO_FLAGS(a1)
  2771.         clr.w    ioa_AllocKey(a1)
  2772.         move.l    #AnyChannel,ioa_Data(a1)
  2773.         move.l    #4,ioa_Length(a1)
  2774.         move.l    AudioPort(a4),MN_REPLYPORT(a1)
  2775.         move.b    #-50,LN_PRI(a1)
  2776.         moveq    #0,d1                ; suggested by UISG
  2777.         CALLSYS    OpenDevice
  2778.         tst.l    d0
  2779.         beq.s    .NoError
  2780.         moveq    #0,d0                ; Disable
  2781.         move.b    d0,KeyClick(a4)            ; ... the click function
  2782.         bra.s    .NoClickYet
  2783. .NoError    move.l    AudioReq(a4),a1            ; Let`s hear it for the click
  2784.         move.w    #CMD_WRITE,IO_COMMAND(a1)
  2785.         move.b    #ADIOF_PERVOL,IO_FLAGS(a1)
  2786.         move.w    #450,ioa_Period(a1)
  2787.         move.l    ClickVol(a4),d0
  2788.         move.w    d0,ioa_Volume(a1)
  2789.         move.l    #CLICKLEN,ioa_Length(a1)
  2790.         move.l    #ClickData,ioa_Data(a1)
  2791.         move.w    #1,ioa_Cycles(a1)
  2792.         move.l    AudioPort(a4),MN_REPLYPORT(a1)
  2793.         move.b    #-50,LN_PRI(a1)
  2794.         move.l    IO_DEVICE(a1),a6
  2795.         jsr    DEV_BEGINIO(a6)
  2796. .WaitClick    move.l    AudioReq(a4),a1            ; Wait until request is finished
  2797.         CALLSYS    CheckIO
  2798.         tst.l    d0
  2799.         beq.s    .WaitClick
  2800.         move.l     AudioReq(a4),a1        ; Close device again and
  2801.         DOLIB    CloseDevice            ; free channels
  2802.  
  2803. .NoClickYet    tst.b    ScrTimeOut(a4)            ; Screen blanked ?
  2804.         beq.s    .NoScr
  2805.         bsr    GetSemaphore
  2806.         move.l    EventMsg(a4),a0
  2807.         lea    req_IEvent(a0),a0
  2808.         lea    ie_TimeStamp(a0),a0        ; Reset screen delay
  2809.         move.l    TV_SECS(a0),d0
  2810.         add.l    ScreenTime(a4),d0
  2811.         move.l    d0,ScreenOff(a4)
  2812.         clr.b    ScrTimeOut(a4)            ; Screen timed out
  2813.         bsr    FreeSemaphore
  2814.         bsr    OnScreen            ; UnBlank it
  2815. .NoScr        bra    EventDone
  2816.  
  2817. NoKeyEvent    move.l    EventMsg(a4),a0
  2818.         cmp.l    #REQ_RAWMOUSE,LN_NAME(a0)
  2819.         bne.s    NoMouseEvent
  2820.  
  2821.         tst.b    ScrTimeOut(a4)
  2822.         beq.s    .NoScr
  2823.         bsr    OnScreen            ; Activate screen if not blanked
  2824. .NoScr        clr.b    ScrTimeOut(a4)            ; out anymore
  2825.         bsr    OnMouse
  2826.         bra    EventDone
  2827.  
  2828. NoMouseEvent    move.l    EventMsg(a4),a0            ; Work window cycling
  2829.         cmp.l    #REQ_CYCLE,LN_NAME(a0)
  2830.         bne    NoCycleEvent
  2831.  
  2832.         move.l    EventMsg(a4),a1
  2833.         lea    req_IEvent(a1),a1
  2834.         move.w    ie_Code(a1),d0
  2835.         move.w    ie_Qualifier(a1),d1
  2836.         and.w    #~(IEQUALIFIER_REPEAT|IEQUALIFIER_NUMERICPAD|IEQUALIFIER_INTERRUPT|IEQUALIFIER_RELATIVEMOUSE|IEQUALIFIER_MULTIBROADCAST),d1
  2837.         bsr    FilterDouble
  2838.         cmp.w    FrontCode(a4),d0
  2839.         bne.s    .NotFront
  2840.         cmp.w    FrontQual(a4),d1
  2841.         beq    .CheckCycle
  2842. .NotFront    cmp.w    BackCode(a4),d0
  2843.         bne.s    .NotBack
  2844.         cmp.w    BackQual(a4),d1
  2845.         beq    .NoPopFront
  2846. .NotBack    cmp.w    #IECODE_MBUTTON,d0
  2847.         bne    .EndCycle
  2848.         cmp.w    MiddleQual(a4),d1
  2849.         bne    .EndCycle
  2850.  
  2851.         cmp.w    #1,MiddleClicks(a4)
  2852.         beq.s    .DoBackM
  2853.         tst.l    MCycleSecs(a4)
  2854.         bge.s    .CheckDoubleM
  2855. .RemakeDoubleM    move.l    EventMsg(a4),a1
  2856.         lea    req_IEvent(a1),a1
  2857.         lea    ie_TimeStamp(a1),a1
  2858.         move.l    TV_SECS(a1),MCycleSecs(a4)    ; Copy current system ticks
  2859.         move.l    TV_MICRO(a1),MCycleMicro(a4)
  2860.         bra    .RemakeCounters
  2861. .CheckDoubleM    subq.w    #1,ThisMiddleClick(a4)
  2862.         bgt    .EndCycle
  2863.         move.l    EventMsg(a4),a1
  2864.         lea    req_IEvent(a1),a1
  2865.         lea    ie_TimeStamp(a1),a1
  2866.         movem.l    MCycleSecs(a4),d0-d1
  2867.         move.l    TV_SECS(a1),d2
  2868.         move.l    TV_MICRO(a1),d3
  2869.         move.l    #-1,MCycleSecs(a4)
  2870.         RELLIB    DoubleClick,_IntuitionBase
  2871.         tst.l    d0
  2872.         beq.s    .RemakeDoubleM
  2873. .DoBackM    move.l    _IntuitionBase(a4),a0
  2874.         move.l    ib_FirstScreen(a0),a0
  2875.         bra    .PopScrBack
  2876.  
  2877. .CheckCycle    moveq    #-1,d0
  2878.         move.l    d0,BCycleSecs(a4)
  2879.         move.l    d0,MCycleSecs(a4)
  2880.         cmp.w    #1,FrontClicks(a4)
  2881.         beq    .OneFront
  2882.         tst.l    FCycleSecs(a4)            ; Double click to front ?
  2883.         bge.s    .CheckDoubleF
  2884. .RemakeDouble    move.l    EventMsg(a4),a1
  2885.         lea    req_IEvent+ie_TimeStamp(a1),a1
  2886.         move.l    TV_SECS(a1),FCycleSecs(a4)    ; Copy current system ticks
  2887.         move.l    TV_MICRO(a1),FCycleMicro(a4)
  2888.         clr.l    CycledWin(a4)            ; Clear window pointer
  2889.         clr.l    CycledScreen(a4)        ; Clear screen pointer
  2890.         RELLIB    FindWindow,_KCXBase        ; Find a layer
  2891.         tst.l    d0                ; Got one ?
  2892.         beq    .RemakeCounters            ; Nope -> No window
  2893.         move.l    a0,CycledScreen(a4)
  2894.         move.l    d0,a0
  2895.         move.l    lr_Window(a0),CycledWin(a4)    ; Store pointer to window
  2896.         bra    .RemakeCounters
  2897. .CheckDoubleF    RELLIB    FindWindow,_KCXBase        ; Check if window is still the same
  2898.         cmp.l    CycledScreen(a4),a0        ; Same screen ?
  2899.         bne.s    .RemakeDouble            ; Nope -> remake
  2900.         tst.l    d0                ; Got a window ?
  2901.         beq.s    .NoWindow            ; Nope -> go on
  2902.         move.l    d0,a1                ; Window the same a last one ?
  2903.         move.l    lr_Window(a1),d1        ; Layer with a window ?
  2904.         beq.s    .NoWindow            ; Nope -> Could be a screen
  2905.         cmp.l    CycledWin(a4),d1        ; Window the same ? Nope -> go on
  2906.         bne.s    .RemakeDouble
  2907. .NoWindow    subq.w    #1,ThisFrontClick(a4)
  2908.         bgt    .EndCycle
  2909.         movem.l    d0/a0,-(sp)
  2910.         move.l    EventMsg(a4),a1
  2911.         movem.l    FCycleSecs(a4),d0-d1        ; Check for double click
  2912.         lea    req_IEvent(a1),a1
  2913.         lea    ie_TimeStamp(a1),a1
  2914.         move.l    TV_SECS(a1),d2
  2915.         move.l    TV_MICRO(a1),d3
  2916.         move.l    #-1,FCycleSecs(a4)
  2917.         RELLIB    DoubleClick,_IntuitionBase
  2918.         movem.l    (sp)+,d1/a0
  2919.         tst.l    d0                ; Click OK ?
  2920.         beq    .RemakeDouble            ; Nope -> Remake ticks
  2921.         tst.l    d1                ; Did we have a layer ?
  2922.         beq.s    .PopScrFront            ; Nope -> check for screen
  2923.         move.l    d1,d0                ; Check window
  2924.         bra.s    .SpecToFront
  2925. .OneFront    RELLIB    FindWindow,_KCXBase        ; Find window underneith layer
  2926.         tst.l    d0
  2927.         beq.s    .PopScrFront            ; No layer, no window
  2928. .SpecToFront    move.l    d0,a5
  2929.         move.l    lr_Window(a5),d1        ; Layer with window ?
  2930.         beq.s    .PopScrFront            ; Nope -> screen
  2931.         move.l    lr_ClipRect(a5),a1        ; Window hidden by others ?
  2932.         move.l    a1,d0
  2933.         beq    .EndCycle
  2934.         tst.l    cr_Next(a1)
  2935.         beq    .EndCycle
  2936.         move.l    lr_Window(a5),a5
  2937.         move.l    wd_Flags(a5),d1
  2938.         move.l    d1,d2
  2939.         and.l    #WFLG_BACKDROP,d1        ; BackDrop window -> Pop Screen
  2940.         bne.s    .PopScrFront
  2941.         and.l    #WFLG_DEPTHGADGET,d2        ; Does the window have a DEPTH-Gad ???
  2942.         beq    .EndCycle            ; Nope -> no pop to front
  2943.         move.l    a5,a0
  2944.         RELLIB    WindowToFront,_IntuitionBase
  2945.         bra.s    .EndFront
  2946. .PopScrFront    move.l    a0,d0                ; Got Screen address ???
  2947.         beq    .EndCycle
  2948.         move.l    a0,-(sp)
  2949.         moveq    #0,d0
  2950.         RELLIB    LockIBase,_IntuitionBase
  2951.         move.l    ib_FirstScreen(a6),a2
  2952.         move.l    d0,a0
  2953.         DOLIB    UnlockIBase
  2954.         move.l    (sp)+,a0
  2955.         cmp.l    a2,a0
  2956.         beq.s    .EndFront
  2957.         DOLIB    ScreenToFront            ; Pop screen to front
  2958. .EndFront    bra    .EndCycle
  2959. .NoPopFront    moveq    #-1,d0
  2960.         move.l    d0,FCycleSecs(a4)
  2961.         move.l    d0,MCycleSecs(a4)
  2962.  
  2963.  
  2964.         cmp.w    #1,BackClicks(a4)
  2965.         beq    .OneBack
  2966.         tst.l    BCycleSecs(a4)            ; Double click to front ?
  2967.         bge.s    .CheckDoubleB
  2968. .RemakeDoubleB    move.l    EventMsg(a4),a1
  2969.         lea    req_IEvent(a1),a1
  2970.         lea    ie_TimeStamp(a1),a1
  2971.         move.l    TV_SECS(a1),BCycleSecs(a4)    ; Copy current system ticks
  2972.         move.l    TV_MICRO(a1),BCycleMicro(a4)
  2973.         clr.l    CycledWin(a4)            ; Clear window pointer
  2974.         clr.l    CycledScreen(a4)        ; Clear screen pointer
  2975.         RELLIB    FindWindow,_KCXBase        ; Find a layer
  2976.         tst.l    d0                ; Got one ?
  2977.         beq    .RemakeCounters            ; Nope -> No window
  2978.         move.l    a0,CycledScreen(a4)
  2979.         move.l    d0,a0
  2980.         move.l    lr_Window(a0),CycledWin(a4)    ; Store pointer to window
  2981.         bra    .RemakeCounters
  2982. .CheckDoubleB    RELLIB    FindWindow,_KCXBase        ; Check if window is still the same
  2983.         cmp.l    CycledScreen(a4),a0        ; Same screen ?
  2984.         bne.s    .RemakeDoubleB            ; Nope -> remake
  2985.         tst.l    d0                ; Got a window ?
  2986.         beq.s    .NoWindowB            ; Nope -> go on
  2987.         move.l    d0,a1                ; Window the same a last one ?
  2988.         move.l    lr_Window(a1),d1        ; Layer with a window ?
  2989.         beq.s    .NoWindowB            ; Nope -> Could be a screen
  2990.         cmp.l    CycledWin(a4),d1        ; Window the same ? Nope -> go on
  2991.         bne.s    .RemakeDoubleB
  2992. .NoWindowB    subq.w    #1,ThisBackClick(a4)
  2993.         bgt    .EndCycle
  2994.         movem.l    d0/a0,-(sp)
  2995.         move.l    EventMsg(a4),a1
  2996.         movem.l    BCycleSecs(a4),d0-d1        ; Check for double click
  2997.         lea    req_IEvent(a1),a1
  2998.         lea    ie_TimeStamp(a1),a1
  2999.         move.l    TV_SECS(a1),d2
  3000.         move.l    TV_MICRO(a1),d3
  3001.         move.l    #-1,BCycleSecs(a4)
  3002.         RELLIB    DoubleClick,_IntuitionBase
  3003.         movem.l    (sp)+,d1/a0
  3004.         tst.l    d0                ; Click OK ?
  3005.         beq    .RemakeDoubleB            ; Nope -> Remake ticks
  3006.         tst.l    d1                ; Did we have a layer ?
  3007.         beq.s    .PopScrBack            ; Nope -> check for screen
  3008.         move.l    d1,d0                ; Check window
  3009.         bra.s    .SpecToBack
  3010. .OneBack    RELLIB    FindWindow,_KCXBase        ; Find layer
  3011.         tst.l    d0
  3012.         beq.s    .PopScrBack            ; No layer, no window
  3013. .SpecToBack    move.l    d0,a1
  3014.         move.l    lr_Window(a1),a1
  3015.         move.l    a1,d0                ; Got a window ?
  3016.         beq.s    .PopScrBack
  3017.         move.l    wd_Flags(a1),d0
  3018.         move.l    d0,d1
  3019.         and.l    #WFLG_BACKDROP,d0        ; BackDrop window ?
  3020.         bne.s    .PopScrBack
  3021.         and.l    #WFLG_DEPTHGADGET,d1        ; DEPTH-Gad there ?
  3022.         beq    EventDone            ; Nope -> go on
  3023.         tst.l    wd_NextWindow(a1)
  3024.         bne.s    .ToBack
  3025.         move.l    wd_WScreen(a1),a0
  3026.         cmp.l    sc_FirstWindow(a0),a1
  3027.         beq    EventDone
  3028. .ToBack        move.l    a1,-(sp)
  3029.         RELLIB    WaitTOF,_GfxBase        ; Wait a bit so that
  3030.                             ; the ButtonUp message can arrive
  3031.         move.l    (sp)+,a0
  3032.         RELLIB    WindowToBack,_IntuitionBase
  3033.         bra    EventDone
  3034. .PopScrBack    move.l    a0,d0                ; If we have a screen ->
  3035.         beq    EventDone            ; Let it pop
  3036.         RELLIB    ScreenToBack,_IntuitionBase
  3037. .EndCycle    bra    EventDone
  3038. .RemakeCounters    move.w    FrontClicks(a4),d0        ; Reset click counter
  3039.         subq.w    #1,d0
  3040.         move.w    d0,ThisFrontClick(a4)
  3041.         move.w    MiddleClicks(a4),d0        ; Reset click counter
  3042.         subq.w    #1,d0
  3043.         move.w    d0,ThisMiddleClick(a4)
  3044.         move.w    BackClicks(a4),d0        ; Reset click counter
  3045.         subq.w    #1,d0
  3046.         move.w    d0,ThisBackClick(a4)
  3047.         bra.s    .EndCycle
  3048.  
  3049. NoCycleEvent    move.l    EventMsg(a4),a0            ; Disk Event ?
  3050.         cmp.l    #REQ_DISKCHANGE,LN_NAME(a0)
  3051.         bne    NoDiskChEvent
  3052.  
  3053.         bsr    OnScreen
  3054.  
  3055.         link    a5,#-4
  3056.  
  3057.         move.l    #id_SIZEOF,d0            ; Allocate InfoData Buffer
  3058.         move.l    #MEMF_CLEAR,d1
  3059.         CALLSYS    AllocVec
  3060.         move.l    d0,-4(a5)
  3061.         tst.l    d0
  3062.         beq    .Error
  3063.  
  3064.         lea    DriveList(a4),a1        ; Check, which drive was changed
  3065.         lea    DriveChange(a4),a2
  3066.         lea    DriveRequests(a4),a3
  3067.         moveq    #0,d7
  3068. .FindDrive    tst.l    (a3)
  3069.         beq    .NotThisOne
  3070.         movem.l    a1/a2,-(sp)
  3071.         move.l    (a3),a1
  3072.         move.w    #TD_CHANGENUM,IO_COMMAND(a1)    ; Get number of changes for one drive
  3073.         clr.b    IO_FLAGS(a1)
  3074.         CALLSYS    DoIO
  3075.         movem.l    (sp)+,a1/a2
  3076.         move.l    (a3),a0
  3077.         move.l    IO_ACTUAL(a0),d0
  3078.         move.l    (a2),d1
  3079.         move.l    d0,(a2)
  3080.         cmp.l    d1,d0                ; Check with previous number of changes
  3081.         ble    .NotThisOne
  3082.         move.l    a1,-(sp)            ; If that`s our drive, get address of handler
  3083.         move.l    (a1),d1
  3084.         RELLIB    DeviceProc,_DOSBase
  3085.         move.l    (sp)+,a1
  3086.         tst.l    d0
  3087.         beq.s    .NotThisOne
  3088.         movem.l    d7/a1,-(sp)            ; Ask DOS to tell us the state of the disk
  3089.         move.l    d0,d1
  3090.         move.l    #ACTION_DISK_INFO,d2
  3091.         move.l    -4(a5),d3
  3092.         lsr.l    #2,d3
  3093.         moveq    #0,d4
  3094.         moveq    #0,d5
  3095.         moveq    #0,d6
  3096.         moveq    #0,d7
  3097.         DOLIB    DoPkt
  3098.         movem.l    (sp)+,d7/a1
  3099.         tst.l    d0
  3100.         beq.s    .NotThisOne
  3101.         move.l    -4(a5),a0            ; Check for Disk-Status
  3102.         cmp.l    #ID_UNREADABLE_DISK,id_DiskType(a0)
  3103.         beq.s    .ThisOne
  3104.         cmp.l    #ID_NOT_REALLY_DOS,id_DiskType(a0)
  3105.         bne.s    .NotThisOne
  3106. .ThisOne    move.w    d7,FormatDrive(a4)        ; This is the number of drive to be formatted
  3107.         lea    DriveThere(a4),a0        ; Which drive is within this slot ???
  3108.         moveq    #0,d0
  3109.         move.b    0(a0,d7.w),d0            ; Get Drive Number
  3110.         lea    Watch0(a4),a0            ; Check whether drive is to be checked
  3111.         tst.b    0(a0,d0.w)            ; Flag clear -> no check
  3112.         beq.s    .NotThisOne
  3113.         move.l    -4(a5),a1
  3114.         CALLSYS    FreeVec
  3115.         tst.l    FormHandle(a4)            ; Formatter window open ???
  3116.         bne.s    .EndDisk
  3117.         unlk    a5                ; Nope, tell mother to ask user
  3118.         move.l    BackTask(a4),a1
  3119.         move.l    FormatSigFlag(a4),d0
  3120.         DOLIB    Signal
  3121.         bra    EventDone
  3122. .NotThisOne    addq.l    #4,a1                ; Loop for drives
  3123.         addq.l    #4,a2
  3124.         addq.l    #4,a3
  3125.         addq.w    #1,d7
  3126.         cmp.w    NumDrives(a4),d7
  3127.         bne    .FindDrive
  3128.  
  3129. .Error        tst.l    -4(a5)                ; Free buffer
  3130.         beq.s    .EndDisk
  3131.         move.l    -4(a5),a1
  3132.         CALLSYS    FreeVec
  3133. .EndDisk    unlk    a5
  3134.         bra    EventDone
  3135.  
  3136. NoDiskChEvent    move.l    EventMsg(a4),a0            ; Scr to back ?
  3137.         cmp.l    #REQ_SCRBACK,LN_NAME(a0)
  3138.         bne.s    NoScrBackEvent
  3139.         CALLSYS    Forbid                ; Send active screen to back
  3140.         moveq    #0,d0
  3141.         RELLIB    LockIBase,_IntuitionBase
  3142.         move.l    ib_FirstScreen(a6),a2
  3143.         move.l    d0,a0
  3144.         DOLIB    UnlockIBase
  3145.         CALLSYS    Permit
  3146.         move.l    a2,d0
  3147.         beq    EventDone
  3148.         move.l    a2,a0
  3149.         RELLIB    ScreenToBack,_IntuitionBase
  3150.         bra    EventDone
  3151.  
  3152. NoScrBackEvent    move.l    EventMsg(a4),a0            ; WB to front ?
  3153.         cmp.l    #REQ_WBFRONT,LN_NAME(a0)
  3154.         bne.s    NoWBFrontEvent            ; Pick up WB-Screen
  3155.         RELLIB    WBenchToFront,_IntuitionBase
  3156.         bra    EventDone
  3157.  
  3158. NoWBFrontEvent    move.l    EventMsg(a4),a0            ; Unblank screen ???
  3159.         cmp.l    #REQ_ONSCREEN,LN_NAME(a0)
  3160.         bne.s    NoOnScreen
  3161.         bsr    OnScreen
  3162.         bra    EventDone
  3163.  
  3164. NoOnScreen    move.l    EventMsg(a4),a0            ; Timer Event ?
  3165.         cmp.l    #REQ_TIMER,LN_NAME(a0)
  3166.         bne    EventDone
  3167.  
  3168.         CALLSYS    Forbid
  3169.         tst.b    ShowClock(a4)
  3170.         beq.s    .NoRemakeFont
  3171.         link    a5,#-4                ; Check for system font
  3172.         moveq    #0,d7                ; within titlebar
  3173.         bsr    LockScreen
  3174.         tst.l    d0
  3175.         beq.s    .NoScreen
  3176.         move.l    d0,a0
  3177.         move.l    sc_BarLayer(a0),a1
  3178.         move.l    lr_rp(a1),a1
  3179.         move.l    rp_Font(a1),d1
  3180.         cmp.l    OldSysFont(a4),d1        ; Still the same font used ?
  3181.         bne.s    .NewFont            ; Yep -> go on
  3182.         move.l    a0,a1
  3183.         move.l    sc_RastPort+rp_BitMap(a1),a1
  3184.         moveq    #0,d0
  3185.         move.b    bm_Depth(a1),d0
  3186.         cmp.w    BitMapDepth(a4),d0
  3187.         beq.s    .NoFont
  3188. .NewFont    moveq    #1,d7
  3189. .NoFont        bsr    UnlockScreen
  3190. .NoScreen    unlk    a5
  3191.         tst.b    d7
  3192.         beq.s    .NoRemakeFont
  3193. .Lock        bsr    ClearTitleBar
  3194.         bsr    RemoveGfx
  3195.         bsr    InitGfx
  3196.  
  3197. .NoRemakeFont    CALLSYS    Permit
  3198.         bsr    CheckOnline            ; Set new online time
  3199.         bsr    SetTime                ; Set new time
  3200.  
  3201.         tst.b    TimeReset(a4)            ; Reset timers ?
  3202.         beq.s    .NoTime                ; (if times were altered)
  3203.         move.l    EventMsg(a4),a0
  3204.         lea    req_IEvent(a0),a0
  3205.         bsr    ResetTimer
  3206.         bra    .NoMouseOff
  3207. .NoTime        tst.b    Disabled(a4)            ; Only blank when not disabled
  3208.         bne    .NoMouseOff
  3209.         move.l    EventMsg(a4),a0
  3210.         lea    req_IEvent(a0),a0
  3211.         lea    ie_TimeStamp(a0),a0
  3212.         tst.b    DoBlankNow(a4)
  3213.         bne.s    .BlankNow
  3214.         tst.b    ScrTimeOut(a4)
  3215.         bne.s    .NoScreenOff
  3216.         tst.l    ScreenTime(a4)            ; Screen to be blanked ?
  3217.         beq.s    .NoScreenOff            ; nope -> go on
  3218.         move.l    ScreenOff(a4),d0        ; Screen timeout ?
  3219.         sub.l    TV_SECS(a0),d0
  3220.         bge.s    .NoScreenOff            ; Nope -> go on
  3221. .BlankNow    move.l    TV_SECS(a0),d1            ; Set time for next timeout
  3222.         add.l    ScreenTime(a4),d1
  3223.         add.l    #10,d1
  3224.         move.l    d1,ScreenOff(a4)
  3225.         tst.b    DoBlankNow(a4)
  3226.         bne.s    .ComeOnBlank
  3227.         cmp.l    #-10,d0
  3228.         blt.s    .NoScreenOff
  3229. .ComeOnBlank    clr.b    DoBlankNow(a4)
  3230.         ST    ScrTimeOut(a4)            ; Screen and mouse are timed out
  3231.         CALLSYS    Forbid
  3232.         bsr    OffScreen
  3233.         CALLSYS    Permit
  3234. .NoScreenOff    tst.l    MouseTime(a4)            ; Mouse to be blanked ?
  3235.         beq.s    .NoMouseOff            ; Nope -> go on
  3236.         move.l    EventMsg(a4),a0            ; Check, whether time for
  3237.         lea    req_IEvent(a0),a0
  3238.         lea    ie_TimeStamp(a0),a0        ; blank has come
  3239.         move.l    MouseOff(a4),d0
  3240.         sub.l    TV_SECS(a0),d0
  3241.         bge.s    .NoMouseOff            ; Nope -> go on
  3242.         move.l    TV_SECS(a0),d1            ; Store new values for next
  3243.         add.l    MouseTime(a4),d1        ; blank.
  3244.         addq.l    #1,d1
  3245.         move.l    d1,MouseOff(a4)
  3246.         cmp.l    #-10,d0
  3247.         blt.s    .NoMouseOff
  3248.         bsr    OffMouse            ; Blank mouse
  3249.  
  3250. .NoMouseOff
  3251. EventDone    move.l    EventMsg(a4),a1
  3252.         clr.l    LN_NAME(a1)
  3253.         bra    EventMsgLoop            ; Loop for remaining messages
  3254. **********************************************************************
  3255. *                   Table for converting "Umlauts"                   *
  3256. **********************************************************************
  3257. UmlautTab    dc.w    'ä',$20,$12        ; Ae
  3258.         dc.w    'Ä',$20,$12
  3259.         dc.w    'ö',$18,$12        ; Oe
  3260.         dc.w    'Ö',$18,$12
  3261.         dc.w    'ü',$16,$12        ; Ue
  3262.         dc.w    'Ü',$16,$12
  3263.         dc.w    'ß',$21,$21        ; ss
  3264.         dc.w    0,0,0
  3265.  
  3266.  
  3267.  
  3268.  
  3269.  
  3270. **********************************************************************
  3271. *                   Check the BillWindow-Messages                    *
  3272. **********************************************************************
  3273. CheckBillWindow    move.l    BillHandle(a4),a0        ; Get message
  3274.         move.l    wd_UserPort(a0),a0
  3275.         RELLIB    GT_GetIMsg,_GadToolsBase
  3276.         tst.l    d0
  3277.         beq    NoBillMsg
  3278.         move.l    d0,a1
  3279.  
  3280.         move.l    im_Class(a1),d6
  3281.         move.w    im_Qualifier(a1),d4
  3282.         moveq    #0,d5
  3283.         move.w    im_Code(a1),d5
  3284.         move.l    d6,d0
  3285.         and.l    #(IDCMP_GADGETUP|IDCMP_GADGETDOWN),d0
  3286.         beq.s    .NoGad
  3287.         move.l    im_IAddress(a1),a0
  3288.         move.w    gg_GadgetID(a0),d7
  3289.  
  3290. .NoGad        DOLIB    GT_ReplyIMsg
  3291.  
  3292.         cmp.l    #IDCMP_VANILLAKEY,d6        ; Key hit ?
  3293.         bne.s    .NoVKey
  3294.         cmp.b    #ESCKEY,d5            ; ESC
  3295.         bne.s    .NoEsc
  3296.         move.l    #IDCMP_CLOSEWINDOW,d6        ; Promote to CLOSEWINDOW
  3297.         bra.s    .NoVKey
  3298. .NoEsc        lea    BillGads(a4),a3            ; Check, which gadget`s ke was hit
  3299.         moveq    #0,d1
  3300. .FindGad    move.l    (a3),d2
  3301.         beq.s    .NoVKey
  3302.         move.l    d5,d0
  3303.         bsr    GetUpperCase
  3304.         move.l    d2,a0
  3305.         move.l    gg_UserData(a0),d2
  3306.         cmp.b    d0,d2
  3307.         bne.s    .NextGad
  3308.         cmp.l    #GD_LogCall,d1
  3309.         blt.s    .NoVKey
  3310.         move.l    #IDCMP_GADGETUP,d6        ; Promote to gadgetup message
  3311.         moveq    #-1,d5
  3312.         move.l    d1,d7
  3313.         bra.s    .NoVKey
  3314. .NextGad    addq.l    #4,a3
  3315.         addq.l    #1,d1
  3316.         bra.s    .FindGad
  3317.  
  3318. .NoVKey        cmp.l    #IDCMP_CLOSEWINDOW,d6        ; Window close ???
  3319.         bne.s    NoBillClose
  3320. BillClose    bsr    CloseBillWin
  3321.         bra    NoBillMsg
  3322.  
  3323. NoBillClose    cmp.l    #IDCMP_CHANGEWINDOW,d6        ; Window moved/zoomed ?
  3324.         bne.s    NoBillChange
  3325.         move.l    BillHandle(a4),a0
  3326.         move.l    wd_Flags(a0),d0
  3327.         and.l    #WFLG_ZOOMED,d0
  3328.         bne.s    .IsZoomed
  3329.         clr.b    Zipped(a4)
  3330.         move.l    BillHandle(a4),a0
  3331.         lea    BillWinLeft(a4),a1        ; Store pos for normal size
  3332.         bsr    StoreWinPos
  3333.         move.l    BillHandle(a4),a0
  3334.         lea    BillTitle(a4),a1
  3335.         suba.l    a2,a2
  3336.         subq.w    #1,a2
  3337.         RELLIB    SetWindowTitles,_IntuitionBase
  3338.         bsr    RemakeCosts
  3339.         bra    CheckBillWindow
  3340. .IsZoomed    move.b    #1,Zipped(a4)            ; Store pos for zoomed size
  3341.         move.w    wd_LeftEdge(a0),BillZoomSize(a4)
  3342.         move.w    wd_TopEdge(a0),BillZoomSize+2(a4)
  3343.         bsr    RemakeCosts
  3344.         bra    CheckBillWindow
  3345.  
  3346. NoBillChange    cmp.l    #IDCMP_GADGETDOWN,d6
  3347.         bne.s    NoBillGadDown
  3348.  
  3349.         cmp.w    #GD_BillTimeMX,d7        ; Changed timezone ?
  3350.         bne.s    NoTimeZoneGad
  3351.         move.b    #1,DoRemakeCosts(a4)
  3352.         ext.l    d5
  3353.         move.l    d5,TimeZone(a4)
  3354.         bsr    RemakeCosts
  3355.         bra    CheckBillWindow
  3356.  
  3357. NoTimeZoneGad    cmp.w    #GD_BillCheap,d7        ; Changed timemode
  3358.         bne    CheckBillWindow
  3359.         move.b    #1,DoRemakeCosts(a4)
  3360.         move.b    #1,DontCheckTime(a4)
  3361.         move.b    d5,CheapMode(a4)
  3362.         bsr    RemakeCosts
  3363.         bra    CheckBillWindow
  3364.  
  3365. NoBillGadDown    cmp.l    #IDCMP_GADGETUP,d6        ; GadgetUp ?
  3366.         bne.s    NoBillGadUp
  3367.  
  3368.         cmp.w    #GD_LogCall,d7            ; Enable/Disable phone logs ?
  3369.         bne.s    NoLogCallGad
  3370.         bchg    #0,LogCalls(a4)
  3371.         move.b    LogCalls(a4),d0
  3372.         move.l    #GD_LogCall,d1
  3373.         lea    BillGads(a4),a0
  3374.         move.l    BillHandle(a4),a1
  3375.         RELLIB    SetCheckBox,_KCXBase
  3376.         bsr    RemakeCosts
  3377.         bra    CheckBillWindow
  3378.  
  3379. NoLogCallGad    cmp.w    #GD_BillStart,d7        ; Start bill counting ?
  3380.         bne.s    NoBillStartGad
  3381.         tst.l    d5
  3382.         bge.s    .NoKey
  3383.         move.l    d7,d0
  3384.         lea    BillGads(a4),a0
  3385.         move.l    BillHandle(a4),a5
  3386.         bsr    ButtonCheck
  3387. .NoKey        ST    BillRunning(a4)
  3388.         bra    CheckBillWindow
  3389.  
  3390. NoBillStartGad    cmp.w    #GD_BillStop,d7            ; Stop bill counting ?
  3391.         bne    CheckBillWindow
  3392.         tst.l    d5
  3393.         bge.s    .NoKey
  3394.         move.l    d7,d0
  3395.         lea    BillGads(a4),a0
  3396.         move.l    BillHandle(a4),a5
  3397.         bsr    ButtonCheck
  3398. .NoKey        SF    BillRunning(a4)
  3399.         bra    CheckBillWindow
  3400.  
  3401. NoBillGadUp    cmp.l    #IDCMP_VANILLAKEY,d6        ; Key pressed ?
  3402.         bne    CheckBillWindow
  3403.  
  3404.         cmp.w    #KD_BillTime1,d5        ; Change time zone ?
  3405.         blt.s    NoTimeKeys
  3406.         cmp.w    #KD_BillTime3,d5
  3407.         bgt.s    NoTimeKeys
  3408.         sub.w    #'1',d5                ; Calc new zone
  3409.         move.b    #1,DoRemakeCosts(a4)
  3410.         ext.l    d5
  3411.         move.l    d5,TimeZone(a4)
  3412.         move.l    #GD_BillTimeMX,d0
  3413.         move.l    d5,d1
  3414.         lea    BillGads(a4),a0
  3415.         move.l    BillHandle(a4),a1
  3416.         RELLIB    SetMXGad,_KCXBase
  3417.         bsr    RemakeCosts
  3418.         bra    CheckBillWindow
  3419.  
  3420. NoTimeKeys    cmp.w    #KD_BillNormal,d5        ; Activate normal time mode ?
  3421.         bne.s    NoNormalKey
  3422.         clr.b    CheapMode(a4)
  3423. SetNewTariff    move.b    #1,DoRemakeCosts(a4)
  3424.         move.b    #1,DontCheckTime(a4)
  3425.         move.l    #GD_BillCheap,d0
  3426.         moveq    #0,d1
  3427.         move.b    CheapMode(a4),d1
  3428.         lea    BillGads(a4),a0
  3429.         move.l    BillHandle(a4),a1
  3430.         RELLIB    SetMXGad,_KCXBase
  3431.         bsr    RemakeCosts
  3432.         bra    CheckBillWindow
  3433.  
  3434. NoNormalKey    cmp.w    #KD_BillCheap,d5            ; Activate cheap time mode ?
  3435.         bne    CheckBillWindow
  3436.         move.b    #1,CheapMode(a4)
  3437.         bra    SetNewTariff
  3438. NoBillMsg    rts
  3439.  
  3440.  
  3441.  
  3442.  
  3443. **********************************************************************
  3444. *          This is the process to check for ARexx-Commands           *
  3445. **********************************************************************
  3446. RexxChecker    movem.l    RegsAll,-(sp)
  3447.  
  3448.         move.l    ZeroBase(pc),a4
  3449.  
  3450.         bsr    InitARexx            ; Init ARexx-Port
  3451.         tst.l    d0
  3452.         beq.s    NoRexx
  3453.  
  3454.         move.l    BackTask(a4),a1            ; Signal mother A.Ok
  3455.         move.l    #SIGHANDSHAKE,d0
  3456.         CALLSYS    Signal
  3457.  
  3458.         sub.l    a1,a1                ; Store address to this proc
  3459.         CALLSYS    FindTask
  3460.         move.l    d0,RexxProc(a4)
  3461.  
  3462. CheckRexx    move.l    #SIGHANDSHAKE,d0        ; Wait for signals
  3463.         or.l    ARexxSigFlag(a4),d0
  3464.         CALLSYS    Wait
  3465.         move.l    d0,RexxSig(a4)
  3466.  
  3467.         move.l    RexxSig(a4),d0            ; Remove Process ?
  3468.         and.l    #SIGHANDSHAKE,d0
  3469.         bne.s    NoRexx
  3470.  
  3471.         move.l    RexxSig(a4),d0            ; Did it come from ARexx ?
  3472.         and.l    ARexxSigFlag(a4),d0
  3473.         beq.s    CheckRexx
  3474.         bsr    HandleARexx            ; Handle ARexx commands
  3475.         bra    CheckRexx
  3476.  
  3477. NoRexx        bsr    RemoveARexx            ; Remove ARexx-Port
  3478.  
  3479.         move.l    BackTask(a4),a1            ; Signal mother A.Ok
  3480.         move.l    #SIGHANDSHAKE,d0
  3481.         CALLSYS    Signal
  3482.  
  3483.         movem.l    (sp)+,RegsAll
  3484.         rts
  3485.  
  3486.  
  3487.  
  3488.  
  3489. **********************************************************************
  3490. *                 Check the main part of this proggy                 *
  3491. **********************************************************************
  3492. CheckBroker    tst.w    QuitBroker(a4)            ; Quit our broker ?
  3493.         bne    AbortBroker
  3494.  
  3495.         move.l    #SIGBREAKF_CTRL_C,d0        ; Accept a BREAK (like from c:break)
  3496.         or.l    BrokerSigFlag(a4),d0        ; Wait for sig on port of broker
  3497.         or.l    AlarmSigFlag(a4),d0        ; ... Display alarm
  3498.         or.l    FormatSigFlag(a4),d0        ; ... Formatter
  3499.         or.l    AppSigFlag(a4),d0        ; ... of App-Icon
  3500.         or.l    DragSigFlag(a4),d0        ; ... do dragging
  3501.         or.l    FormWinSig(a4),d0        ; ... Format window
  3502.         or.l    SelScrWinSig(a4),d0        ; ... Select Screen window
  3503.         or.l    BackPortSig(a4),d0        ; ... Communications Port
  3504.         CALLSYS    Wait
  3505.         move.l    d0,ThisSig(a4)
  3506.  
  3507.         and.l    #SIGBREAKF_CTRL_C,d0
  3508.         bne    AbortBroker
  3509.  
  3510.         move.l    ThisSig(a4),d0            ; Got signal from child to
  3511.         and.l    AlarmSigFlag(a4),d0        ; alarm
  3512.         beq.s    NoAlarmDisp
  3513.  
  3514.         link    a5,#-4
  3515.         bsr    LockScreen
  3516.         tst.l    d0
  3517.         beq.s    .Error
  3518.  
  3519.         tst.b    AlarmSample(a4)
  3520.         beq.s    .PlayBeep
  3521.         tst.b    SampleLoaded(a4)
  3522.         bne.s    .PlaySample
  3523. .PlayBeep    move.l    -4(a5),a0            ; Make it beep
  3524.         DOLIB    DisplayBeep
  3525.         bra.s    .BeepDone
  3526.  
  3527. .PlaySample    bsr    PlayAlarm
  3528.  
  3529. .BeepDone    tst.b    DoShowAlarm(a4)            ; Show the requester ???
  3530.         beq.s    .Error
  3531.  
  3532.         CALLSYS    Forbid
  3533.         bsr    OnScreen            ; Turn on everything, so that
  3534.         CALLSYS    Permit
  3535.         bsr    OnMouse                ; User can see what`s up
  3536.  
  3537.         lea    MyEasyRequest,a1        ; Display Easy-Requester
  3538.         move.l    #EasyTitle,es_Title(a1)
  3539.         LOCLEA    AlarmReqText,es_TextFormat(a1)
  3540.         move.l    #EasyGadget,es_GadgetFormat(a1)
  3541.         sub.l    a0,a0
  3542.         sub.l    a2,a2
  3543.         sub.l    a3,a3
  3544.         RELLIB    EasyRequestArgs,_IntuitionBase
  3545.  
  3546. .Error        bsr    UnlockScreen
  3547.         unlk    a5
  3548.  
  3549. NoAlarmDisp    move.l    ThisSig(a4),d0
  3550.         and.l    BrokerSigFlag(a4),d0        ; If it was on the Msg-Port
  3551.         beq    NoCxMsgs
  3552.  
  3553. WorkAllMsgs    move.l    BrokerPort(a4),a0        ; Check the msgs
  3554.         CALLSYS    GetMsg
  3555.         tst.l    d0
  3556.         beq    NoCxMsgs
  3557.         move.l    d0,a3
  3558.  
  3559.         move.l    a3,a0                ; Get Msg-Type
  3560.         LNKLIB    CxMsgType,_CxBase
  3561.         move.l    d0,MsgType(a4)
  3562.  
  3563.         move.l    a3,a0                ; Get ID of msg
  3564.         DOLIB    CxMsgID
  3565.         move.l    d0,MsgID(a4)
  3566.  
  3567.         move.l    a3,a1
  3568.         CALLSYS    ReplyMsg
  3569.  
  3570.         cmp.l    #CXM_COMMAND,MsgType(a4)    ; Commodities command ?
  3571.         bne    NoXCommand            ; Yep -> go on
  3572.  
  3573.         move.l    MsgID(a4),d0
  3574.  
  3575.         cmp.l    #CXCMD_KILL,d0            ; Are we to go away ?
  3576.         bne.s    NoKill
  3577.         move.w    #1,QuitBroker(a4)
  3578.         bra    WorkAllMsgs
  3579.  
  3580. NoKill        cmp.l    #CXCMD_APPEAR,d0        ; Mainwindow openuo ?
  3581.         bne.s    NoMainOpenUp
  3582.         bsr    OpenMainWin
  3583.         bra    WorkAllMsgs
  3584.  
  3585. NoMainOpenUp    cmp.l    #CXCMD_DISAPPEAR,d0        ; Mainwindow closedown ?
  3586.         bne.s    NoMainCloseDown
  3587.         move.l    PrefsPort(a4),a0
  3588.         move.l    BackPort(a4),a1
  3589.         move.l    #COM_REMOVEPREFS,d0
  3590.         RELLIB    ComPut,_KCXBase
  3591.         bra    WorkAllMsgs
  3592.  
  3593. NoMainCloseDown    cmp.l    #CXCMD_DISABLE,d0        ; Disable broker ?
  3594.         bne.s    DontDisable
  3595.         bsr    DisableBroker
  3596.         move.b    #1,Disabled(a4)
  3597.         bra    WorkAllMsgs
  3598.  
  3599. DontDisable    cmp.l    #CXCMD_ENABLE,d0        ; Enable ???
  3600.         bne.s    DontEnable
  3601.         move.b    #1,TimeReset(a4)
  3602.         clr.b    Disabled(a4)
  3603.         bsr    EnableBroker
  3604.         bra    WorkAllMsgs
  3605.  
  3606. DontEnable    cmp.l    #CXCMD_UNIQUE,d0        ; Another broker with same name
  3607.         bne.s    NoUnique            ; -> Quit program
  3608.         move.w    #1,QuitBroker(a4)
  3609. NoUnique    bra    WorkAllMsgs
  3610.  
  3611. NoXCommand    cmp.l    #CXM_IEVENT,MsgType(a4)        ; Pop up key used ???
  3612.         bne    WorkAllMsgs            ; Nope -> Loop for msgs
  3613.  
  3614.         cmp.l    #POPUPKEYID,MsgID(a4)        ; Open external Prefs proggy ??
  3615.         bne.s    NoOpenPrefs
  3616.         bsr    OpenMainWin
  3617.         bra    WorkAllMsgs
  3618.  
  3619. NoOpenPrefs    cmp.l    #PAGEKEYID,MsgID(a4)        ; Change display mode of time ?
  3620.         bne.s    NoPageChange
  3621.         cmp.l    #SNAPMEMPAGE,PageNum(a4)
  3622.         bne.s    .GoOn
  3623.         move.l    OldPageNum(a4),d0            ; Restore old Page
  3624.         move.l    d0,PageNum(a4)
  3625.         bra.s    .End1
  3626. .GoOn        addq.l    #1,PageNum(a4)
  3627.         cmp.l    #MAXPAGES,PageNum(a4)
  3628.         blt.s    .End
  3629.         clr.l    PageNum(a4)
  3630. .End        move.l    PageNum(a4),d0
  3631.         move.l    d0,OldPageNum(a4)
  3632. .End1        CALLSYS    Forbid
  3633.         bsr    ClearTitleBar
  3634.         bsr    SigTime
  3635.         CALLSYS    Permit
  3636.         bra    WorkAllMsgs
  3637.  
  3638. NoPageChange    cmp.l    #BILLKEYID,MsgID(a4)        ; Pop Up Bill window ?
  3639.         bne.s    NoBillHotKey
  3640.         move.l    CheckerProc(a4),a1
  3641.         move.l    #SIGBILLWIN,d0
  3642.         CALLSYS    Signal
  3643.         bra    WorkAllMsgs
  3644.  
  3645. NoBillHotKey    cmp.l    #SHELLKEYID,MsgID(a4)        ; Pop Up Shell ?
  3646.         bne    NoShellPop
  3647.         lea    SystemInOut(pc),a0
  3648.         move.l    a0,d1                ; Open the dummy Files NIL:
  3649.         move.l    #MODE_NEWFILE,d2
  3650.         RELLIB    Open,_DOSBase
  3651.         move.l    d0,SysInput
  3652.         move.l    #SystemInOut,d1
  3653.         move.l    #MODE_NEWFILE,d2
  3654.         DOLIB    Open
  3655.         move.l    d0,SysOutput
  3656.         move.l    BackTask(a4),a0            ; Make Path-List, only if NOT
  3657.         tst.l    pr_CLI(a0)            ; Startet from CLI
  3658.         beq.s    .NoPath
  3659.         move.l    #TAG_DONE,SysCLI        ; Clear remaining tags
  3660.         bra    .GotPath
  3661. .NoPath        move.l    #NP_Path,SysCLI            ; Allow Process tags
  3662.         move.l    pr_CurrentDir(a0),d1        ; Clone mother`s current dir
  3663.         RELLIB    DupLock,_DOSBase
  3664.         tst.l    d0
  3665.         beq    .NoProc
  3666.         move.l    $4.w,a6
  3667.         move.l    d0,SysDir
  3668.         lea    WBPName(pc),a1            ; Try to get a pointer to a process
  3669.         bsr    .FindTaskSub            ; we can clone the pathlist from
  3670.                             ; Try to get the Workbench,
  3671.                             ; AmigaShell, InitialCLI,
  3672.         lea    ICLIName(pc),a1            ; Background CLI or New CLI processes
  3673.         bsr    .FindTaskSub            ; This is needed, so that the new
  3674.                             ; shell may execute Prgs, which
  3675.                             ; are located in dirs you
  3676.         lea    NCLIName(pc),a1            ; worked a PATH on.
  3677.         bsr    .FindTaskSub            ; We have to arrange a pathlist
  3678.                             ; which looks like this :
  3679.                             ; Size of block, Link to next, Lock-BPTR
  3680.         lea    AShellName(pc),a1
  3681.         bsr    .FindTaskSub
  3682.  
  3683.         lea    BCLIName(pc),a1
  3684.         bsr    .FindTaskSub
  3685.  
  3686.         bra    WorkAllMsgs
  3687. .GotProc    DOLIB    Forbid
  3688.         move.l    d0,a0                ; So we have a process -> go on
  3689.         move.l    pr_CLI(a0),d0            ; Get pointer to it`s CLI-Structure
  3690.         lsl.l    #2,d0                ; Convert the BPTR
  3691.         move.l    d0,a0                ; Get pointer to A0
  3692.         move.l    cli_CommandDir(a0),d0        ; Get pointer to CommandDir
  3693.         lsl.l    #2,d0                ; Convert to normal Pointer
  3694.         move.l    d0,a2                ; Store pointer
  3695.         lea    SysPath,a5            ; Get Pointer to Tags-Entry
  3696. .GetPath    move.l    a2,d0                ; No (more) path ?
  3697.         beq.s    .GotPath            ; -> Start Shell
  3698.         moveq    #12,d0                ; Allocate a small link-structure
  3699.         move.l    #MEMF_CLEAR,d1
  3700.         CALLSYS    AllocMem
  3701.         move.l    d0,d1                ; Could not get mem for one more
  3702.         beq.s    .GotPath            ; path lock -> start Shell
  3703.         addq.l    #4,d1                ; Point to middle of these 3 LongWords
  3704.         lsr.l    #2,d1                ; Convert to BPTR
  3705.         move.l    d1,(a5)                ; Store Pointer to structure
  3706.         move.l    d0,a5                ; Let A5 point to new memory block
  3707.         addq.l    #4,a5                ; -> right to the middle
  3708.         move.l    d0,a3                ; Store pointer
  3709.         move.l    4(a2),d1            ; Duplicate Lock to Path
  3710.         RELLIB    DupLock,_DOSBase
  3711.         move.l    d0,8(a3)            ; Store LockPointer
  3712.         clr.l    4(a3)                ; Clear link-pointer
  3713.         move.l    #12,0(a3)            ; Store length of one Path-Entry
  3714.         move.l    (a2),d0                ; Get pointer to mother`s next path
  3715.         lsl.l    #2,d0                ; Convert to normal pointer
  3716.         move.l    d0,a2                ; Now restart for next path
  3717.         bra.s    .GetPath
  3718. .GotPath    CALLSYS    Permit
  3719.         lea    SystemComm(a4),a0
  3720.         move.l    a0,d1                ; Start Shell...
  3721.         lea    SystemTags(pc),a0
  3722.         move.l    a0,d2
  3723.         RELLIB    SystemTagList,_DOSBase
  3724.         tst.l    d0
  3725.         bge.s    .NoProc
  3726.         move.l    SysInput(pc),d1
  3727.         DOLIB    Close
  3728.         move.l    SysOutput(pc),d1
  3729.         DOLIB    Close
  3730. .NoProc        bra    WorkAllMsgs
  3731. .FindTaskSub    DOLIB    FindTask
  3732.         tst.l    d0
  3733.         bne.s    .FoundTask
  3734.         rts
  3735. .FoundTask    addq.w    #4,sp
  3736.         bra    .GotProc
  3737.  
  3738. NoShellPop    cmp.l    #UMLAUTKEYID,MsgID(a4)        ; Change "Umlaut" mode ?
  3739.         bne.s    NoUmlautEx
  3740.         CALLSYS    Forbid
  3741.         bchg    #0,MapUmlaut(a4)
  3742.         move.b    MapUmlaut(a4),d0
  3743.         moveq    #2,d1
  3744.         lea    SetGads(a4),a0
  3745.         move.l    SetHandle(a4),a1
  3746.         RELLIB    SetCheckBox,_KCXBase
  3747.         CALLSYS    Permit
  3748.         bra    WorkAllMsgs
  3749.  
  3750. NoUmlautEx    cmp.l    #SNAPKEYID,MsgID(a4)        ; Snap memory ?
  3751.         bne    NoSnapHotKey
  3752.         tst.b    Snapped(a4)
  3753.         bne.s    .DisplaySnap
  3754.         sub.l    a0,a0                ; Give feedback
  3755.         RELLIB    DisplayBeep,_IntuitionBase
  3756.         CALLSYS    Forbid
  3757.         move.l    #MEMF_CHIP,d1            ; Get current memory settings
  3758.         DOLIB    AvailMem
  3759.         move.l    d0,ThisChip
  3760.         move.l    #MEMF_FAST,d1
  3761.         DOLIB    AvailMem
  3762.         move.l    d0,ThisFast
  3763.         move.b    #1,Snapped(a4)
  3764.         cmp.l    #SNAPMEMPAGE,PageNum(a4)
  3765.         bne.s    .End
  3766.         bsr    ClearTitleBar
  3767.         move.l    OldPageNum(a4),d0
  3768.         move.l    d0,PageNum(a4)
  3769. .End        CALLSYS    Permit
  3770.         bra    WorkAllMsgs
  3771. .DisplaySnap    CALLSYS    Forbid
  3772.         move.l    #MEMF_CHIP,d1            ; Get current memory settings
  3773.         DOLIB    AvailMem
  3774.         sub.l    ThisChip,d0            ; Get delta mem usage
  3775.         move.l    d0,ThisChip
  3776.         move.l    #MEMF_FAST,d1
  3777.         DOLIB    AvailMem
  3778.         sub.l    ThisFast,d0            ; Get delta mem usage
  3779.         move.l    d0,ThisFast
  3780.         move.l    PageNum(a4),d0
  3781.         move.l    d0,OldPageNum(a4)
  3782.         move.l    #SNAPMEMPAGE,PageNum(a4)    ; Switch to correct display
  3783.         clr.b    Snapped(a4)            ; Clear flag
  3784.         bsr    ClearTitleBar
  3785.         bsr    SigTime
  3786.         CALLSYS    Permit
  3787.         bra    WorkAllMsgs
  3788.  
  3789. NoSnapHotKey    cmp.l    #DOBLANKKEYID,MsgID(a4)        ; Blank screen ?
  3790.         bne.s    NoDoBlankHKey
  3791.         move.b    #1,DoBlankNow(a4)
  3792.         bra    WorkAllMsgs
  3793.  
  3794. NoDoBlankHKey    cmp.l    #FORMKEYID,MsgID(a4)        ; Format window ?
  3795.         bne.s    NoFormHKey
  3796.         bsr    OpenFormWin
  3797.         bra    WorkAllMsgs
  3798.  
  3799. NoFormHKey    cmp.l    #DUMPKEYID,MsgID(a4)        ; Dump screen ?
  3800.         bne.s    NoDumpHKey
  3801.         tst.l    PrintProc(a4)
  3802.         bne.s    .End
  3803.         bsr    StartPrinter
  3804. .End        bra    WorkAllMsgs
  3805.  
  3806. NoDumpHKey    cmp.l    #CENTERKEYID,MsgID(a4)        ; Recenter a screen ?
  3807.         bne.s    NoCenterHKey
  3808.         CALLSYS    Forbid
  3809.         moveq    #0,d0
  3810.         RELLIB    LockIBase,_IntuitionBase
  3811.         move.l    d0,-(sp)
  3812.         bsr    GetDispCols
  3813.         move.l    ib_FirstScreen(a6),a3
  3814.         move.l    (sp)+,a0
  3815.         DOLIB    UnlockIBase
  3816.         move.l    a3,d0
  3817.         beq.s    .End
  3818.         move.l    a3,a0
  3819.         move.w    sc_ViewPort+vp_Modes(a0),d1
  3820.         andi.w    #V_HIRES|V_SUPERHIRES,d1
  3821.         bne.s    .SuperHigh
  3822.         lsr.w    #1,d5
  3823.         bra.s    .MoveOK
  3824. .SuperHigh    andi.w    #V_SUPERHIRES,d1
  3825.         beq.s    .MoveOK
  3826.         add.w    d5,d5
  3827. .MoveOK        sub.w    sc_Width(a0),d5
  3828.         bls.s    .End
  3829.         lsr.w    #1,d5
  3830.         sub.w    sc_LeftEdge(a0),d5
  3831.         beq.s    .End
  3832.         moveq    #0,d1
  3833.         move.w    d5,d0
  3834.         RELLIB    MoveScreen,_IntuitionBase
  3835. .End        CALLSYS    Permit
  3836.         bra    WorkAllMsgs
  3837.  
  3838. NoCenterHKey    cmp.l    #SELECTSCRKEYID,MsgID(a4)    ; Pop a screen to front ?
  3839.         bne.s    NoSelScrHKey
  3840.         bsr    OpenSelScrWin
  3841.         bra    WorkAllMsgs
  3842.  
  3843. NoSelScrHKey    cmp.l    #CLOCKKEYID,MsgID(a4)        ; On/Off clock ???
  3844.         bne.s    NoClockHKey
  3845.         CALLSYS    Forbid
  3846.         bchg    #0,ShowClock(a4)
  3847.         move.b    ShowClock(a4),d0
  3848.         move.l    #0,d1                ; Set gadget within clock def window
  3849.         lea    ClockDefGads(a4),a0
  3850.         move.l    ClockDefHandle(a4),a1
  3851.         RELLIB    SetCheckBox,_KCXBase
  3852.         bsr    ClearTitleBar
  3853.         bsr    CloseClockWin
  3854.         bsr    SigTime
  3855.         CALLSYS    Permit
  3856.         bra    WorkAllMsgs
  3857.  
  3858. NoClockHKey    cmp.l    #FKEYKEYID,MsgID(a4)        ; On/Off FKeys ???
  3859.         bne.s    NoFKeyHKey
  3860.         CALLSYS    Forbid
  3861.         bchg    #0,FKeysOn(a4)
  3862.         move.b    FKeysOn(a4),d0
  3863.         move.l    #11,d1                ; Set gadget within clock def window
  3864.         lea    FKeyGads(a4),a0
  3865.         move.l    FKeyHandle(a4),a1
  3866.         RELLIB    SetCheckBox,_KCXBase
  3867.         CALLSYS    Permit
  3868.         bra    WorkAllMsgs
  3869.  
  3870. NoFKeyHKey    cmp.l    #SUNKEYID,MsgID(a4)        ; On/Off SunMouse ???
  3871.         bne.s    NoSunHKey
  3872.         CALLSYS    Forbid
  3873.         bchg    #0,SunMouse(a4)
  3874.         move.b    SunMouse(a4),d0
  3875.         moveq    #1,d1
  3876.         lea    MouseGads(a4),a0
  3877.         move.l    MouseHandle(a4),a1
  3878.         RELLIB    SetCheckBox,_KCXBase
  3879.         CALLSYS    Permit
  3880. NoSunHKey    bra    WorkAllMsgs
  3881.  
  3882. NoCxMsgs    move.l    ThisSig(a4),d0            ; Formatter window ?
  3883.         and.l    FormWinSig(a4),d0
  3884.         beq    NoFormWinSig
  3885. .Loop        move.l    FormHandle(a4),a0
  3886.         move.l    wd_UserPort(a0),a0
  3887.         RELLIB    GT_GetIMsg,_GadToolsBase
  3888.         tst.l    d0
  3889.         beq    CheckBroker
  3890.  
  3891.         move.l    d0,a1
  3892.         move.l    im_Class(a1),d6            ; Get class
  3893.         moveq    #0,d5
  3894.         move.w    im_Code(a1),d5            ; Get code
  3895.         cmp.l    #IDCMP_VANILLAKEY,d6
  3896.         bne.s    .End
  3897.         move.w    im_Qualifier(a1),d4
  3898.         move.l    d5,d0
  3899.         bsr    GetUpperCase
  3900.         move.l    d0,d5
  3901. .End        move.l    d6,d0
  3902.         and.l    #(IDCMP_GADGETUP|IDCMP_GADGETDOWN),d0
  3903.         beq.s    .NoGad
  3904.         move.l    im_IAddress(a1),a2        ; Get gadget id
  3905.         move.w    gg_GadgetID(a2),d7
  3906.  
  3907. .NoGad        DOLIB    GT_ReplyIMsg            ; Reply gadtools msg
  3908.         cmp.l    #IDCMP_VANILLAKEY,d6
  3909.         bne.s    .NoVKey
  3910.         cmp.b    #ESCKEY,d5
  3911.         bne.s    .NoEsc
  3912.         move.l    #IDCMP_CLOSEWINDOW,d6
  3913.         bra.s    .NoVKey
  3914. .NoEsc        lea    FormGads(a4),a3
  3915.         moveq    #0,d1
  3916. .FindGad    move.l    (a3),d0
  3917.         beq.s    .NoVKey
  3918.         move.l    d0,a0
  3919.         move.l    gg_UserData(a0),d0
  3920.         cmp.b    d0,d5
  3921.         bne.s    .NextGad
  3922.         move.l    #IDCMP_GADGETUP,d6
  3923.         moveq    #-1,d5
  3924.         move.l    d1,d7
  3925.         bra.s    .NoVKey
  3926. .NextGad    addq.l    #4,a3
  3927.         addq.l    #1,d1
  3928.         bra.s    .FindGad
  3929. .NoVKey        bsr    HandleFormWin
  3930.         tst.l    FormHandle(a4)
  3931.         beq    CheckBroker
  3932.         bra    .Loop
  3933.  
  3934. NoFormWinSig    move.l    ThisSig(a4),d0            ; Select Screen window ?
  3935.         and.l    SelScrWinSig(a4),d0
  3936.         beq    NoSelScrWinSig
  3937. .Loop        move.l    SelScrHandle(a4),a0
  3938.         move.l    wd_UserPort(a0),a0
  3939.         RELLIB    GT_GetIMsg,_GadToolsBase
  3940.         tst.l    d0
  3941.         beq    CheckBroker
  3942.  
  3943.         move.l    d0,a1
  3944.         move.l    im_Class(a1),d6            ; Get class
  3945.         moveq    #0,d5
  3946.         move.w    im_Code(a1),d5            ; Get code
  3947.         cmp.l    #IDCMP_VANILLAKEY,d6
  3948.         bne.s    .End
  3949.         move.w    im_Qualifier(a1),d4
  3950.         move.l    d5,d0
  3951.         bsr    GetUpperCase
  3952.         move.l    d0,d5
  3953. .End        move.l    d6,d0
  3954.         and.l    #(IDCMP_GADGETUP|IDCMP_GADGETDOWN),d0
  3955.         beq.s    .NoGad
  3956.         move.l    im_IAddress(a1),a2        ; Get gadget id
  3957.         move.w    gg_GadgetID(a2),d7
  3958.  
  3959. .NoGad        move.l    a1,a3                ; For current time
  3960.         DOLIB    GT_ReplyIMsg            ; Reply gadtools msg
  3961.         cmp.l    #IDCMP_VANILLAKEY,d6
  3962.         bne.s    .NoVKey
  3963.         cmp.b    #ESCKEY,d5
  3964.         bne.s    .NoEsc
  3965.         move.l    #IDCMP_CLOSEWINDOW,d6
  3966.         bra.s    .NoVKey
  3967. .NoEsc        lea    SelScrGads(a4),a3
  3968.         moveq    #0,d1
  3969. .FindGad    move.l    (a3),d0
  3970.         beq.s    .NoVKey
  3971.         move.l    d0,a0
  3972.         move.l    gg_UserData(a0),d0
  3973.         cmp.b    d0,d5
  3974.         bne.s    .NextGad
  3975.         move.l    #IDCMP_GADGETUP,d6
  3976.         moveq    #-1,d5
  3977.         move.l    d1,d7
  3978.         bra.s    .NoVKey
  3979. .NextGad    addq.l    #4,a3
  3980.         addq.l    #1,d1
  3981.         bra.s    .FindGad
  3982. .NoVKey        bsr    HandleSelScrWin
  3983.         tst.l    SelScrHandle(a4)
  3984.         beq    CheckBroker
  3985.         bra    .Loop
  3986.  
  3987. NoSelScrWinSig
  3988.         move.l    ThisSig(a4),d0            ; App-Message ?
  3989.         and.l    AppSigFlag(a4),d0
  3990.         beq.s    NoAppMsg
  3991.  
  3992. .LoopAppMsg    move.l    AppPort(a4),a0            ; Get message
  3993.         CALLSYS    GetMsg
  3994.         tst.l    d0
  3995.         beq.s    NoAppMsg
  3996.         move.l    d0,a1
  3997.         cmp.w    #MTYPE_APPICON,am_Type(a1)    ; Did it come from window ?
  3998.         bne.s    .NoAppIcon
  3999.         tst.l    am_NumArgs(a1)
  4000.         bne.s    .ReplyAppMsg
  4001.         tst.l    am_ArgList(a1)
  4002.         bne.s    .ReplyAppMsg
  4003.         move.l    a1,-(sp)
  4004.         bsr    OpenMainWin            ; Open our window
  4005.         move.l    (sp)+,a1
  4006.         bra.s    .ReplyAppMsg
  4007. .NoAppIcon    cmp.w    #MTYPE_APPMENUITEM,am_Type(a1)    ; Was a menu item ?
  4008.         bne.s    .ReplyAppMsg
  4009.         cmp.l    #MAINITEM,am_ID(a1)        ; The control-window ?
  4010.         bne.s    .ReplyAppMsg
  4011.         move.l    a1,-(sp)
  4012.         bsr    OpenMainWin            ; Open it
  4013.         move.l    (sp)+,a1
  4014. .ReplyAppMsg    CALLSYS    ReplyMsg
  4015.         bra    .LoopAppMsg
  4016.  
  4017. NoAppMsg    move.l    ThisSig(a4),d0            ; Signal for formatter ?
  4018.         and.l    FormatSigFlag(a4),d0
  4019.         beq.s    NoFormSig
  4020.         bsr    CheckFormat
  4021.  
  4022. NoFormSig    move.l    ThisSig(a4),d0            ; Signal for dragging ?
  4023.         and.l    DragSigFlag(a4),d0
  4024.         beq.s    NoDragSig
  4025.         bsr    DoDragging
  4026.  
  4027. NoDragSig    move.l    ThisSig(a4),d0            ; Signal from Com-Port ?
  4028.         and.l    BackPortSig(a4),d0
  4029.         beq    CheckBroker
  4030.         move.l    BackPort(a4),a0
  4031.         CALLSYS    GetMsg
  4032.         tst.l    d0
  4033.         beq    CheckBroker
  4034.         move.l    d0,a1
  4035.         move.w    cmsg_Type(a1),d0        ; Get Type
  4036.  
  4037.         IFGT    DEBUG                ; Some debug information
  4038.         DBUG    .ComOut,d0,#0
  4039.         bra.s    .End
  4040. .ComOut        dc.b    "COM-MESSAGE %.2lx",10,0
  4041.         EVEN
  4042. .End
  4043.         ENDC
  4044.         move.l    a1,-(sp)
  4045.         cmp.w    #COM_DISABLE,d0            ; Disable Broker ???
  4046.         bne.s    .NoDisable
  4047.         bsr    DisableBroker
  4048.         bra    .DoneCom
  4049. .NoDisable    cmp.w    #COM_ENABLE,d0            ; Enable Broker ???
  4050.         bne.s    .NoEnable
  4051.         bsr    EnableBroker
  4052.         bra    .DoneCom
  4053. .NoEnable    cmp.w    #COM_CLEARTITLE,d0        ; Clear titlebar ???
  4054.         bne.s    .NoClearTitle
  4055.         bsr    ClearTitleBar
  4056.         bra    .DoneCom
  4057. .NoClearTitle    cmp.w    #COM_CLOSECLOCK,d0        ; Close clock window ???
  4058.         bne.s    .NoCloseClock
  4059.         bsr    CloseClockWin
  4060.         bra    .DoneCom
  4061. .NoCloseClock    cmp.w    #COM_SETNOCLICK,d0        ; Set click ?
  4062.         bne.s    .NoSetClick
  4063.         bsr    SetNoClick
  4064.         bra    .DoneCom
  4065. .NoSetClick    cmp.w    #COM_OPENFORM,d0        ; Open Formatter window ?
  4066.         bne.s    .NoOpenForm
  4067.         bsr    OpenFormWin
  4068.         bra    .DoneCom
  4069. .NoOpenForm    cmp.w    #COM_REMOVE,d0            ; Remove background stuff ?
  4070.         bne.s    .NoBackRem
  4071.         move.w    #1,QuitBroker(a4)
  4072.         bra    .DoneCom
  4073. .NoBackRem    cmp.w    #COM_APPICONON,d0        ; Show AppIcon ?
  4074.         bne.s    .NoAppOn
  4075.         bsr    OnAppIcon
  4076.         bra    .DoneCom
  4077. .NoAppOn    cmp.w    #COM_APPICONOFF,d0        ; Hide AppIcon ?
  4078.         bne.s    .NoAppOff
  4079.         bsr    OffAppIcon
  4080.         bra    .DoneCom
  4081. .NoAppOff    cmp.w    #COM_DELENVS,d0            ; Delete Environment vars ?
  4082.         bne.s    .NoDelEnvs
  4083.         bsr    DeleteEnvs
  4084.         bra    .DoneCom
  4085. .NoDelEnvs    cmp.w    #COM_NEWPREFS,d0        ; New prefs loaded ???
  4086.         bne.s    .NoNewPrefs
  4087.         bsr    SetBillGads
  4088.         bsr    SetFormGads
  4089.         move.b    #1,DoRemakeCosts(a4)
  4090.         bsr    RemakeCosts
  4091.         bra.s    .NewAlarmSmp
  4092. .NoNewPrefs    cmp.w    #COM_NEWALARM,d0        ; New alarm sample ???
  4093.         bne.s    .NoNewAlarmSmp
  4094. .NewAlarmSmp    bsr    RemoveAlarmSmp
  4095.         bsr    InitAlarmSmp
  4096.         bra.s    .DoneCom
  4097. .NoNewAlarmSmp    cmp.w    #COM_PLAYALARM,d0        ; Play alarm sample ???
  4098.         bne.s    .NoPlayAlarm
  4099.         bsr    PlayAlarm
  4100.         bra.s    .DoneCom
  4101. .NoPlayAlarm    cmp.w    #COM_REMAKECOSTS,d0        ; Remake costs ???
  4102.         bne.s    .NoRemakeCosts
  4103.         bsr    RemakeCosts
  4104.         bra.s    .DoneCom
  4105. .NoRemakeCosts    cmp.w    #COM_PRINTER,d0            ; Start printer ???
  4106.         bne.s    .NoStartPrint
  4107.         bsr    StartPrinter
  4108.         bra.s    .DoneCom
  4109. .NoStartPrint    cmp.w    #COM_REBLACK,d0            ; Reblack Border ???
  4110.         bne.s    .NoBlackBorder
  4111.         move.l    GlobalTagAdr(a4),d0
  4112.         beq.s    .DoneCom
  4113.         move.l    d0,a0
  4114.         move.l    #VTAG_BORDERBLANK_SET,d0
  4115.         tst.b    tagscr_BlackBorder(a0)
  4116.         bne.s    .GoOn
  4117.         move.l    #VTAG_BORDERBLANK_CLR,d0
  4118. .GoOn        move.l    d0,BlackTags
  4119.         bsr    ReBlackBorder2
  4120.         bra.s    .DoneCom
  4121. .NoBlackBorder    cmp.w    #COM_FLICKER,d0            ; Remove/Install Flicker IRQ ?
  4122.         bne.s    .NoFlicker
  4123.         tst.b    FlickerOff(a4)
  4124.         beq.s    .Remove
  4125.         bsr    InitFlickerIRQ
  4126.         bra.s    .DoneCom
  4127. .Remove        bsr    RemFlickerIRQ
  4128.         bra.s    .DoneCom
  4129. .NoFlicker
  4130. .DoneCom    move.l    (sp)+,a1
  4131.         CALLSYS    ReplyMsg
  4132.         bra    CheckBroker            ; Loop for all stuff
  4133. AbortBroker    tst.l    PrintProc(a4)
  4134.         beq.s    .NoPrinter
  4135.         move.l    #STILLPRINT_ERR,ErrorBack(a4)
  4136.         bsr    DisplayError
  4137.         clr.w    QuitBroker(a4)
  4138.         bra    CheckBroker
  4139.  
  4140. .NoPrinter    tst.b    CheckQuit(a4)
  4141.         beq.s    .NoQuit
  4142.         lea    MyEasyRequest(pc),a1
  4143.         move.l    #EasyTitle,es_Title(a1)
  4144.         LOCLEA    QuitText,a0
  4145.         move.l    a0,es_TextFormat(a1)
  4146.         LOCLEA    QuitGads,a0
  4147.         move.l    a0,es_GadgetFormat(a1)
  4148.         sub.l    a0,a0
  4149.         sub.l    a2,a2
  4150.         sub.l    a3,a3
  4151.         RELLIB    EasyRequestArgs,_IntuitionBase
  4152.         clr.w    QuitBroker(a4)
  4153.         tst.l    d0
  4154.         beq    CheckBroker
  4155. .NoQuit        rts
  4156. **********************************************************************
  4157. *                  Tags for use to open a new shell                  *
  4158. **********************************************************************
  4159. SystemTags    dc.l    SYS_Input
  4160. SysInput    dc.l    0
  4161.         dc.l    SYS_Output
  4162. SysOutput    dc.l    0
  4163.         dc.l    SYS_Asynch
  4164.         dc.l    1
  4165.         dc.l    NP_Priority
  4166.         dc.l    0
  4167. SysCLI        dc.l    NP_Path
  4168. SysPath        dc.l    0
  4169.         dc.l    NP_CurrentDir
  4170. SysDir        dc.l    0
  4171.         dc.l    TAG_DONE
  4172. DefSystemComm    dc.b    "NewSHELL CON:0/11//200/KCX-Shell/CLOSE/ALT///50/50",0
  4173. SystemInOut    dc.b    "NIL:",0
  4174. WBPName        dc.b    "Workbench",0            ; Names of processes we want
  4175.                             ; to clone path-lists from :-)
  4176. NCLIName    dc.b    "New CLI",0
  4177. ICLIName    dc.b    "Initial CLI",0
  4178. AShellName    dc.b    "AmigaShell",0
  4179. BCLIName    dc.b    "Background CLI",0
  4180.         EVEN
  4181.  
  4182.  
  4183.  
  4184.  
  4185. **********************************************************************
  4186. *                    Handle the formatter window                     *
  4187. **********************************************************************
  4188. HandleFormWin    cmp.l    #IDCMP_CLOSEWINDOW,d6        ; Close window ?
  4189.         beq    CloseFormWin
  4190.  
  4191.         cmp.l    #IDCMP_CHANGEWINDOW,d6        ; Window moved ?
  4192.         bne.s    NoFormMove
  4193.         move.l    FormHandle(a4),a0
  4194.         lea    FormWinLeft(a4),a1
  4195.         bra    StoreWinPos
  4196.  
  4197. NoFormMove    cmp.l    #IDCMP_GADGETUP,d6        ; Gadget picked ?
  4198.         bne    NoFormGadUp
  4199.  
  4200.         cmp.w    #GD_Label,d7            ; Changed Label ?
  4201.         bne.s    NoLabelGad
  4202.         tst.l    d5
  4203.         bge.s    NoLabelKey
  4204. LabelKey    move.l    #GD_Label,d0
  4205.         lea    FormGads(a4),a0
  4206.         move.l    FormHandle(a4),a1
  4207.         RELLIB    ActStringGad,_KCXBase
  4208.         rts
  4209. NoLabelKey    move.l    d7,d0                ; Copy new string
  4210.         lea    FormGads(a4),a0
  4211.         RELLIB    GetGadgetPtr,_KCXBase
  4212.         move.l    gg_SpecialInfo(a0),a0
  4213.         move.l    si_Buffer(a0),a0
  4214.         lea    FormatDriveName(a4),a1
  4215.         jmp    StrCpy
  4216.  
  4217. NoLabelGad    cmp.w    #GD_Trashcan,d7            ; Trashcan ?
  4218.         bne.s    NoTrashGad
  4219.         bchg    #0,MakeIcons(a4)
  4220.         move.b    MakeIcons(a4),d0
  4221.         move.l    #GD_Trashcan,d1
  4222.         bra    SetFormBox
  4223.  
  4224. NoTrashGad    cmp.w    #GD_Quick,d7            ; Quick format ?
  4225.         bne.s    NoQuickGad
  4226.         bchg    #0,QuickFormat(a4)
  4227.         move.b    QuickFormat(a4),d0
  4228.         move.l    #GD_Quick,d1
  4229.         bra    SetFormBox
  4230.  
  4231. NoQuickGad    cmp.w    #GD_FFS,d7            ; FFS format ?
  4232.         bne.s    NoFFSGad
  4233.         bchg    #0,FFSDrive(a4)
  4234.         move.b    FFSDrive(a4),d0
  4235.         move.l    #GD_FFS,d1
  4236.         bra    SetFormBox
  4237.  
  4238. NoFFSGad    cmp.w    #GD_NoVerify,d7            ; No verify ?
  4239.         bne.s    NoVerifyGad
  4240.         bchg    #0,NoVerify(a4)
  4241.         move.b    NoVerify(a4),d0
  4242.         move.l    #GD_NoVerify,d1
  4243.         bra    SetFormBox
  4244.  
  4245. NoVerifyGad    cmp.w    #GD_Install,d7            ; Install disk ?
  4246.         bne.s    NoInstallGad
  4247.         bchg    #0,Install(a4)
  4248.         move.b    Install(a4),d0
  4249.         move.l    #GD_Install,d1
  4250.         bra    SetFormBox
  4251.  
  4252. NoInstallGad    cmp.w    #GD_Eject,d7            ; Eject disk ?
  4253.         bne.s    NoEjectGad
  4254.         bchg    #0,EjectDrive(a4)
  4255.         move.b    EjectDrive(a4),d0
  4256.         move.l    #GD_Eject,d1
  4257.         bra    SetFormBox
  4258.  
  4259. NoEjectGad    cmp.w    #GD_IntMode,d7            ; International mode ???
  4260.         bne.s    NoIntModeGad
  4261.         tst.b    DirCache(a4)
  4262.         bne.s    .End
  4263.         bchg    #0,InterMode(a4)
  4264.         move.b    InterMode(a4),d0
  4265.         move.b    d0,OldInterMode(a4)
  4266.         move.l    #GD_IntMode,d1
  4267.         bra    SetFormBox
  4268. .End        rts
  4269.  
  4270. NoIntModeGad    cmp.w    #GD_DiskCache,d7        ; Dir Caching ?
  4271.         bne.s    NoDirCacheGad
  4272.         bchg    #0,DirCache(a4)
  4273.         move.b    DirCache(a4),d0
  4274.         beq.s    .UseOldInt
  4275.         moveq    #1,d0
  4276.         move.b    d0,InterMode(a4)
  4277.         moveq    #1,d2
  4278.         bra.s    .SetGad
  4279. .UseOldInt    move.b    OldInterMode(a4),d0
  4280.         move.b    d0,InterMode(a4)
  4281.         moveq    #0,d2
  4282. .SetGad        move.l    #GD_IntMode,d1
  4283.         bsr    SetFormBox
  4284.         move.l    #GD_IntMode,d0
  4285.         move.l    d2,d1
  4286.         DOLIB    GhostGadget
  4287.         move.b    DirCache(a4),d0
  4288.         move.l    #GD_DiskCache,d1
  4289.         bra    SetFormBox
  4290.  
  4291. NoDirCacheGad    cmp.w    #GD_WatchDisks,d7        ; Watch disks ?
  4292.         bne.s    NoWatchGad
  4293.         bchg    #0,WatchDisks(a4)
  4294.         move.b    WatchDisks(a4),d0
  4295.         move.l    #GD_WatchDisks,d1
  4296.         bra    SetFormBox
  4297.  
  4298. NoWatchGad    cmp.w    #GD_Watch0,d7            ; Changed one of the watches ?
  4299.         blt.s    NoWatchesGad
  4300.         cmp.w    #GD_Watch3,d7
  4301.         bgt.s    NoWatchesGad
  4302.         move.w    d7,d6
  4303.         sub.w    #GD_Watch0,d7
  4304.         move.w    d7,d0
  4305.         mulu    #28,d0
  4306.         lea    WatchGads(pc),a0
  4307.         tst.l    4(a0,d0)
  4308.         bne.s    .End
  4309.         lea    Watch0(a4),a0
  4310.         bchg    #0,0(a0,d7.w)
  4311.         move.b    0(a0,d7.w),d0
  4312.         move.l    d6,d1
  4313.         bra    SetFormBox
  4314. .End        rts
  4315.  
  4316. NoWatchesGad    cmp.w    #GD_FormOk,d7            ; Format ?
  4317.         bne.s    NoFormOkGad
  4318.         tst.l    d5
  4319.         bge.s    StartFormat
  4320.         move.l    d7,d0
  4321.         lea    FormGads(a4),a0
  4322.         move.l    FormHandle(a4),a5
  4323.         bsr    ButtonCheck
  4324.         bra.s    StartFormat
  4325.  
  4326. NoFormOkGad    cmp.w    #GD_FormCancel,d7        ; Cancel ?
  4327.         bne.s    NoFormClGad
  4328.         tst.l    d5
  4329.         bge    CloseFormWin
  4330.         move.l    d7,d0
  4331.         lea    FormGads(a4),a0
  4332.         move.l    FormHandle(a4),a5
  4333.         bsr    ButtonCheck
  4334.         bra    CloseFormWin
  4335.  
  4336. NoFormClGad    cmp.w    #GD_Drive,d7            ; New drive selected ?
  4337.         bne.s    NoDriveGad
  4338.         tst.l    d5
  4339.         bge.s    .NoKey
  4340.         move.w    FormatDrive(a4),d5
  4341.         and.w    #IEQUALIFIER_LSHIFT|IEQUALIFIER_RSHIFT,d4
  4342.         beq.s    .Up
  4343.         addq.w    #1,d5
  4344.         cmp.w    NumDrives(a4),d5
  4345.         blt.s    .NoKey
  4346.         moveq    #0,d5
  4347.         bra.s    .NoKey
  4348. .Up        subq.w    #1,d5
  4349.         bge.s    .NoKey
  4350.         move.w    NumDrives(a4),d5
  4351.         subq.w    #1,d5
  4352. .NoKey        move.w    d5,FormatDrive(a4)
  4353.         move.l    #GD_Drive,d0
  4354.         move.w    FormatDrive(a4),d1
  4355.         ext.l    d1
  4356.         lea    FormGads(a4),a0
  4357.         move.l    FormHandle(a4),a1
  4358.         RELLIB    SetCycleGad,_KCXBase
  4359. NoDriveGad    rts
  4360. StartFormat    bsr    GoGoGoFormat            ; Start format
  4361.         bra    CloseFormWin
  4362. NoFormGadUp    rts
  4363.  
  4364.  
  4365.  
  4366.  
  4367.  
  4368.  
  4369. **********************************************************************
  4370. *                     Handle SelectScreen window                     *
  4371. **********************************************************************
  4372. HandleSelScrWin    cmp.l    #IDCMP_CLOSEWINDOW,d6        ; Close window ?
  4373.         beq    CloseSelScrWin
  4374.  
  4375.         cmp.l    #IDCMP_CHANGEWINDOW,d6        ; Window moved ?
  4376.         bne.s    NoSelScrMove
  4377.         move.l    SelScrHandle(a4),a0
  4378.         lea    SelScrWinLeft(a4),a1
  4379.         bra    StoreWinPos
  4380.  
  4381. NoSelScrMove    cmp.l    #IDCMP_GADGETUP,d6        ; Gadget clicked ???
  4382.         bne    NoSelScrGadUp
  4383.  
  4384.         cmp.w    #GD_TaskList,d7            ; New screen selected ???
  4385.         bne    NoTaskListGad
  4386.         tst.l    d5
  4387.         bge.s    .NoKey
  4388.         move.w    SelectedScreen(a4),d0
  4389.         and.w    #IEQUALIFIER_LSHIFT|IEQUALIFIER_RSHIFT,d4
  4390.         bne.s    .Up
  4391.         move.w    NumScreens(a4),d1
  4392.         subq.w    #1,d1
  4393.         cmp.w    d1,d0
  4394.         bge.s    .Done
  4395.         addq.w    #1,d0
  4396.         bra.s    .Done
  4397. .Up        tst.w    d0
  4398.         ble.s    .Done
  4399.         subq.w    #1,d0
  4400. .Done        move.w    d0,SelectedScreen(a4)
  4401.         moveq    #0,d1
  4402.         move.w    d0,d1
  4403.         move.l    d1,d2
  4404.         move.l    #GD_TaskList,d0
  4405.         lea    SelScrGads(a4),a0
  4406.         move.l    SelScrHandle(a4),a1
  4407.         RELLIB    SetListViewGad,_KCXBase
  4408.         rts
  4409. .NoKey        move.w    d5,SelectedScreen(a4)
  4410.         tst.w    LastSelScr(a4)
  4411.         bge.s    .CheckDouble
  4412. .Remake        move.w    d5,LastSelScr(a4)
  4413.         move.l    im_Seconds(a3),LastSelScrSec(a4)
  4414.         move.l    im_Micros(a3),LastSelScrMin(a4)
  4415.         bra.s    .End
  4416. .CheckDouble    cmp.w    LastSelScr(a4),d5
  4417.         bne.s    .Remake
  4418.         move.l    LastSelScrSec(a4),d0
  4419.         move.l    LastSelScrMin(a4),d1
  4420.         move.l    im_Seconds(a3),d2
  4421.         move.l    im_Micros(a3),d3
  4422.         RELLIB    DoubleClick,_IntuitionBase
  4423.         move.w    #-1,LastSelScr(a4)
  4424.         tst.l    d0
  4425.         bne.s    SelScrActKey
  4426. .End        rts
  4427.  
  4428. NoTaskListGad    cmp.w    #GD_SelScrAct,d7        ; Activate screen
  4429.         bne.s    NoSelScrActGad
  4430.         tst.l    d5
  4431.         bge.s    .NoKey
  4432.         move.l    #GD_SelScrAct,d0
  4433.         lea    SelScrGads(a4),a0
  4434.         move.l    SelScrHandle(a4),a5
  4435.         bsr    ButtonCheck
  4436. .NoKey
  4437. SelScrActKey    move.w    SelectedScreen(a4),d0
  4438.         lea    SelScrList(a4),a0
  4439.         move.l    MLH_HEAD(a0),a0
  4440.         sub.l    a1,a1
  4441.         tst.w    d0
  4442.         blt.s    .Done
  4443. .Loop        TSTLST2    a0,a2
  4444.         beq.s    .Done
  4445.         tst.w    d0
  4446.         beq.s    .GotIt
  4447.         move.l    a0,d1
  4448.         beq.s    .Done
  4449.         SUCC    a0,a0
  4450.         subq.w    #1,d0
  4451.         bra.s    .Loop
  4452. .GotIt        move.l    a0,a1
  4453. .Done        move.l    a1,d0
  4454.         beq.s    .End
  4455.         move.l    selscr_Address(a1),a0
  4456.         RELLIB    ScreenToFront,_IntuitionBase
  4457.         bra    CloseSelScrWin
  4458. .End        rts
  4459.  
  4460. NoSelScrActGad    cmp.w    #GD_SelScrCancel,d7        ; Cancel ???
  4461.         bne.s    NoSelScrCancel
  4462.         tst.l    d5
  4463.         bge.s    .NoKey
  4464.         move.l    #GD_SelScrCancel,d0
  4465.         lea    SelScrGads(a4),a0
  4466.         move.l    SelScrHandle(a4),a5
  4467.         bsr    ButtonCheck
  4468. .NoKey        bsr    CloseSelScrWin
  4469.         move.l    LastSelectedScr(a4),a0
  4470.         RELLIB    ScreenToFront,_IntuitionBase
  4471.         rts
  4472.  
  4473. NoSelScrCancel    cmp.w    #GD_SelScrUpdate,d7        ; Update Screen List ?
  4474.         bne    NoSelScrUpGad
  4475.         tst.l    d5
  4476.         bge.s    .NoKey
  4477.         move.l    #GD_SelScrUpdate,d0
  4478.         lea    SelScrGads(a4),a0
  4479.         move.l    SelScrHandle(a4),a5
  4480.         bsr    ButtonCheck
  4481. .NoKey        move.l    #GD_TaskList,d0
  4482.         lea    SelScrGads(a4),a0
  4483.         move.l    SelScrHandle(a4),a1
  4484.         move.l    #~0,a2
  4485.         RELLIB    SetListViewLst,_KCXBase
  4486.         lea    SelScrList(a4),a0
  4487.         DOLIB    FreeWindows
  4488.         bsr    CollectScrs
  4489.         move.l    #GD_TaskList,d0
  4490.         lea    SelScrGads(a4),a0
  4491.         move.l    SelScrHandle(a4),a1
  4492.         lea    SelScrList(a4),a2
  4493.         RELLIB    SetListViewLst,_KCXBase
  4494.         moveq    #0,d1
  4495.         move.w    SelectedScreen(a4),d1
  4496.         move.l    d1,d2
  4497.         DOLIB    SetListViewGad
  4498.         move.l    #GD_SelScrNumScr,d0
  4499.         move.l    ScrNumTag+4,d1
  4500.         DOLIB    SetNumberGad
  4501.         move.l    #GD_SelScrDefPub,d0
  4502.         lea    DefPubScreenName(pc),a2
  4503.         DOLIB    SetTextGad
  4504. NoSelScrUpGad
  4505. NoSelScrGadUp    rts
  4506.  
  4507.  
  4508.  
  4509.  
  4510. **********************************************************************
  4511. *                       Play the alarm sample                        *
  4512. **********************************************************************
  4513. PlayAlarm    tst.b    SampleLoaded(a4)
  4514.         beq    .BeepDone
  4515.  
  4516.         move.l    _GfxBase(a4),a0            ; Get clock rates
  4517.         move.w    gb_DisplayFlags(a0),d0
  4518.         and.w    #PAL,d0
  4519.         beq.s    .IsNTSC
  4520.         move.l    #3546895,d7
  4521.         bra.s    .DoSample
  4522. .IsNTSC        move.l    #3579545,d7
  4523.  
  4524. .DoSample    lea    AudioName(pc),a0        ; Try to open device
  4525.         moveq    #0,d0
  4526.         move.l    AlarmReq(a4),a1
  4527.         move.w    #ADCMD_ALLOCATE,IO_COMMAND(a1)
  4528.         move.b    #ADIOF_NOWAIT,IO_FLAGS(a1)
  4529.         clr.w    ioa_AllocKey(a1)
  4530.         move.l    #AnyChannel,ioa_Data(a1)
  4531.         move.l    #4,ioa_Length(a1)
  4532.         move.l    AlarmPort(a4),MN_REPLYPORT(a1)
  4533.         move.b    #-50,LN_PRI(a1)
  4534.         moveq    #0,d1                ; suggested by UISG
  4535.         CALLSYS    OpenDevice
  4536.         tst.l    d0
  4537.         bne.s    .BeepDone
  4538.  
  4539.         move.l    d7,d0                ; Calculate period
  4540.         moveq    #0,d1
  4541.         move.w    AlarmSmpSec(a4),d1
  4542.         RELLIB    UDivMod32,_UtilityBase
  4543.  
  4544.         move.l    AlarmReq(a4),a1            ; Play alarm
  4545.         move.w    #CMD_WRITE,IO_COMMAND(a1)
  4546.         move.b    #ADIOF_PERVOL,IO_FLAGS(a1)
  4547.         move.l    AlarmSmpStart(a4),ioa_Data(a1)
  4548.         move.l    AlarmSmpLen(a4),ioa_Length(a1)
  4549.         move.w    d0,ioa_Period(a1)
  4550.         move.w    #64,ioa_Volume(a1)
  4551.         move.w    #1,ioa_Cycles(a1)
  4552.         move.l    AlarmPort(a4),MN_REPLYPORT(a1)
  4553.         move.b    #-50,LN_PRI(a1)
  4554.         move.l    IO_DEVICE(a1),a6
  4555.         jsr    DEV_BEGINIO(a6)
  4556.         move.l    AlarmReq(a4),a1
  4557.         CALLSYS    WaitIO
  4558.         move.l    AlarmReq(a4),a1
  4559.         DOLIB    CloseDevice
  4560. .BeepDone    rts
  4561.  
  4562.  
  4563.  
  4564. **********************************************************************
  4565. *                  Start the external Prefs-Proggy                   *
  4566. **********************************************************************
  4567. OpenMainWin    tst.l    MainHandle(a4)            ; Main window already open ?
  4568.         bne.s    .NoPrefsOpen
  4569.         lea    PrefsPath(a4),a0
  4570.         move.l    a0,d1
  4571.         move.l    #ACCESS_READ,d2
  4572.         RELLIB    Lock,_DOSBase
  4573.         tst.l    d0
  4574.         beq.s    .End
  4575.         move.l    d0,d1
  4576.         DOLIB    UnLock
  4577.         lea    SystemInOut(pc),a0
  4578.         move.l    a0,d1
  4579.         move.l    #MODE_OLDFILE,d2
  4580.         DOLIB    Open
  4581.         move.l    d0,PrefsTags+12
  4582.         lea    SystemInOut(pc),a0
  4583.         move.l    a0,d1
  4584.         move.l    #MODE_OLDFILE,d2
  4585.         DOLIB    Open
  4586.         move.l    d0,PrefsTags+20
  4587.         lea    PrefsPath(a4),a0
  4588.         move.l    a0,d1
  4589.         lea    PrefsTags(pc),a0
  4590.         move.l    a0,d2
  4591.         DOLIB    SystemTagList
  4592. .End        rts
  4593. .NoPrefsOpen    CALLSYS    Forbid
  4594.         move.l    MainHandle(a4),a0
  4595.         move.l    wd_WScreen(a0),a0
  4596.         RELLIB    ScreenToFront,_IntuitionBase
  4597.         move.l    MainHandle(a4),a0
  4598.         DOLIB    WindowToFront
  4599.         CALLSYS    Permit
  4600.         rts
  4601. PrefsTags    dc.l    SYS_Asynch,1
  4602.         dc.l    SYS_Input,0
  4603.         dc.l    SYS_Output,0
  4604.         dc.l    NP_Priority,0
  4605.         dc.l    NP_StackSize,8192
  4606.         dc.l    TAG_DONE
  4607.  
  4608.  
  4609.  
  4610. **********************************************************************
  4611. *                 Start the external printer program                 *
  4612. **********************************************************************
  4613. StartPrinter    tst.l    PrintProc(a4)
  4614.         bne.s    .End1
  4615.         lea    PrintPath(a4),a0
  4616.         move.l    a0,d1
  4617.         move.l    #ACCESS_READ,d2
  4618.         RELLIB    Lock,_DOSBase
  4619.         tst.l    d0
  4620.         beq.s    .End1
  4621.         move.l    d0,d1
  4622.         DOLIB    UnLock
  4623.         lea    SystemInOut(pc),a0        ; Start Printer Process
  4624.         move.l    a0,d1
  4625.         move.l    #MODE_OLDFILE,d2
  4626.         DOLIB    Open
  4627.         move.l    d0,PrintTags+12
  4628.         lea    SystemInOut(pc),a0
  4629.         move.l    a0,d1
  4630.         move.l    #MODE_OLDFILE,d2
  4631.         DOLIB    Open
  4632.         move.l    d0,PrintTags+20
  4633.         lea    PrintPath(a4),a0
  4634.         move.l    a0,d1
  4635.         lea    PrintTags(pc),a1
  4636.         move.l    a1,d2
  4637.         DOLIB    SystemTagList
  4638.         tst.l    d0
  4639.         bge.s    .End
  4640.         move.l    PrintTags+12(pc),d1
  4641.         DOLIB    Close
  4642.         move.l    PrintTags+20(pc),d1
  4643.         DOLIB    Close
  4644.         bra.s    .End1
  4645. .End        move.l    #SIGHANDSHAKE,d0
  4646.         CALLSYS    Wait
  4647. .End1        rts
  4648. PrintTags    dc.l    SYS_Asynch,1
  4649.         dc.l    SYS_Input,0
  4650.         dc.l    SYS_Output,0
  4651.         dc.l    NP_Priority,0
  4652.         dc.l    TAG_DONE
  4653.  
  4654.  
  4655.  
  4656.  
  4657. **********************************************************************
  4658. *                     Open the formatter window                      *
  4659. **********************************************************************
  4660. OpenFormWin    tst.l    FormHandle(a4)
  4661.         beq.s    .GoOn
  4662.         move.l    FormHandle(a4),a0
  4663.         RELLIB    WindowToFront,_IntuitionBase
  4664.         rts
  4665. .GoOn        link    a5,#-(4+4+2+2+2+2+gng_SIZEOF)
  4666.         lea    FormTxt(a4),a0
  4667.         move.l    a0,FontPtr(a5)
  4668.         bsr    LockScreen
  4669.         tst.l    d0
  4670.         beq    .FormWinError
  4671.         moveq    #0,d2
  4672.         moveq    #0,d3
  4673.         RELLIB    ComputeFont,_KCXBase
  4674.         move.l    -4(a5),a0
  4675.         sub.l    a1,a1
  4676.         RELLIB    GetVisualInfoA,_GadToolsBase
  4677.         move.l    d0,FormVisInfo(a4)
  4678.         beq    .FormWinError
  4679.  
  4680.         move.l    -4(a5),a0
  4681.         moveq    #0,d3
  4682.         moveq    #0,d2
  4683.         move.w    FormWinWidth(a4),d2
  4684.         move.w    FormWinHeight(a4),d3
  4685.         RELLIB    ComputeFont,_KCXBase
  4686.         move.l    -4(a5),a0
  4687.         move.l    d2,d0
  4688.         DOLIB    ComputeX
  4689.         move.l    d0,d4
  4690.         move.w    FormWinLeft(a4),d2
  4691.         move.l    -4(a5),a3
  4692.         move.w    sc_LeftEdge(a3),d5
  4693.         neg.w    d5
  4694.         add.w    d5,d2
  4695.         add.w    d2,d0
  4696.         add.w    OffX(a5),d0
  4697.         moveq    #0,d1
  4698.         move.b    sc_WBorRight(a0),d1
  4699.         add.w    d1,d0
  4700.         cmp.w    sc_Width(a0),d0
  4701.         bls.s    .WOk
  4702.         move.w    sc_Width(a0),d0
  4703.         sub.w    d4,d0
  4704.         move.w    d0,d2
  4705. .WOk        move.l    d3,d0
  4706.         DOLIB    ComputeY
  4707.         move.l    d0,d4
  4708.         move.w    FormWinTop(a4),d3
  4709.         move.l    -4(a5),a3
  4710.         move.w    sc_TopEdge(a3),d5
  4711.         neg.w    d5
  4712.         add.w    d5,d3
  4713.         add.w    d3,d0
  4714.         add.w    OffY(a5),d0
  4715.         moveq    #0,d1
  4716.         move.b    sc_WBorBottom(a0),d1
  4717.         add.w    d1,d0
  4718.         cmp.w    sc_Height(a0),d0
  4719.         bls.s    .HOk
  4720.         move.w    sc_Height(a0),d0
  4721.         sub.w    d4,d0
  4722.         move.w    d0,d3
  4723. .HOk        lea.l    FormGadget(a4),a0
  4724.         RELLIB    CreateContext,_GadToolsBase
  4725.         move.l    d0,a3
  4726.         beq    .FormWinError
  4727.  
  4728.         movem.l d2-d3/a4,-(sp)
  4729.         moveq    #0,d3
  4730.         lea.l    FormWinGTags,a4
  4731. .FormWinGL    lea.l    FormWinNGads,a0
  4732.         move.l    d3,d0
  4733.         mulu    #gng_SIZEOF,d0
  4734.         add.l    d0,a0
  4735.         lea.l    -(4+4+2+2+2+2+gng_SIZEOF)(a5),a1
  4736.         moveq    #gng_SIZEOF,d0
  4737.         CALLSYS    CopyMem
  4738.         lea.l    -(4+4+2+2+2+2+gng_SIZEOF)(a5),a0
  4739.         move.l    a4,-(sp)
  4740.         move.l    ZeroBase(pc),a4
  4741.         move.l    gng_GadgetText(a0),-(sp)
  4742.         bsr    GetLocStr
  4743.         move.l    (sp)+,d7
  4744.         move.l    d7,gng_GadgetText(a0)
  4745.         move.l    FormVisInfo(a4),gng_VisualInfo(a0)
  4746.         move.l    FontPtr(a5),gng_TextAttr(a0)
  4747.         move.w    gng_LeftEdge(a0),d0
  4748.         RELLIB    ComputeX,_KCXBase
  4749.         move.l    (sp)+,a4
  4750.         add.w    OffX(a5),d0
  4751.         move.w    d0,gng_LeftEdge(a0)
  4752.         move.w    gng_TopEdge(a0),d0
  4753.         DOLIB    ComputeY
  4754.         add.w    OffY(a5),d0
  4755.         move.w    d0,gng_TopEdge(a0)
  4756.         move.w    gng_Width(a0),d0
  4757.         DOLIB    ComputeX
  4758.         move.w    d0,gng_Width(a0)
  4759.         move.w    gng_Height(a0),d0
  4760.         DOLIB    ComputeY
  4761.         move.w    d0,gng_Height(a0)
  4762.         lea.l    FormWinGTypes,a0
  4763.         moveq    #0,d0
  4764.         move.l    d3,d1
  4765.         lsl.l    #1,d1
  4766.         move.w    0(a0,d1.w),d0
  4767.         move.l    a3,a0
  4768.         lea.l    -(4+4+2+2+2+2+gng_SIZEOF)(a5),a1
  4769.         move.l    a4,a2
  4770.         move.l    a4,-(sp)
  4771.         move.l    ZeroBase(pc),a4
  4772.         RELLIB    CreateGadgetA,_GadToolsBase
  4773.         move.l    (sp)+,a4
  4774.         tst.l    d0
  4775.         beq    .FormWinError
  4776.         move.l    d0,a3
  4777.         move.l    d7,a0
  4778.         bsr    LocalizeGadKey
  4779.         move.l    d1,gg_UserData(a3)
  4780.         move.l    d3,d0
  4781.         lsl.l    #2,d0
  4782.         move.l    a4,-(sp)
  4783.         move.l    ZeroBase(pc),a4
  4784.         lea.l    FormGads(a4),a0
  4785.         move.l    (sp)+,a4
  4786.         move.l    a3,0(a0,d0.w)
  4787. .FormWinTL    tst.l    (a4)
  4788.         beq.s    .FormWinDN
  4789.         addq.w    #8,a4
  4790.         bra.s    .FormWinTL
  4791. .FormWinDN    addq.w    #4,a4
  4792.         addq.w    #1,d3
  4793.         cmp.w    #FormWin_CNT,d3
  4794.         bmi    .FormWinGL
  4795.         movem.l (sp)+,d2-d3/a4
  4796.         move.l    FormGadget(a4),FormWinWG+4
  4797.  
  4798.         lea    FormGads(a4),a0
  4799.         bsr    SetStrIntGads
  4800.  
  4801.         LOCLEA    DefFormTitle,a0
  4802.         lea    FormTitle(a4),a1
  4803.         bsr    StrCpy
  4804.         lea    FormatHotKey(a4),a0
  4805.         lea    FormTitle(a4),a1
  4806.         move.l    a1,FormWinWG+12
  4807.         bsr    StrCat
  4808.         LOCLEA    WindowScrTitle,FormWinWG+20
  4809.         move.l    -4(a5),FormWinSC+4        ; Open window
  4810.         ext.l    d2
  4811.         ext.l    d3
  4812.         move.l    d2,FormWinL+4
  4813.         move.l    d3,FormWinT+4
  4814.         move.l    -4(a5),a0
  4815.         move.w    FormWinWidth(a4),d0
  4816.         RELLIB    ComputeX,_KCXBase
  4817.         add.w    OffX(a5),d0
  4818.         moveq    #0,d1
  4819.         move.b    sc_WBorRight(a0),d1
  4820.         add.w    d1,d0
  4821.         move.l    d0,FormWinW+4
  4822.         move.w    FormWinHeight(a4),d0
  4823.         DOLIB    ComputeY
  4824.         add.w    OffY(a5),d0
  4825.         moveq    #0,d1
  4826.         move.b    sc_WBorBottom(a0),d1
  4827.         add.w    d1,d0
  4828.         move.l    d0,FormWinH+4
  4829.         suba.l    a0,a0
  4830.         lea.l    FormWinWindowTags,a1
  4831.         RELLIB    OpenWindowTagList,_IntuitionBase
  4832.         move.l    d0,FormHandle(a4)
  4833.         beq.s    .FormWinError
  4834.         move.l    d0,a0
  4835.         moveq    #0,d0
  4836.         moveq    #1,d1
  4837.         move.l    wd_UserPort(a0),a0
  4838.         move.b    MP_SIGBIT(a0),d0
  4839.         lsl.l    d0,d1
  4840.         move.l    d1,FormWinSig(a4)
  4841.  
  4842.         move.l    FormHandle(a4),a0
  4843.         move.l    wd_RPort(a0),a2
  4844.         move.l    a2,a0
  4845.         lea.l    FormBevelTag(pc),a1
  4846.         move.l    FormVisInfo(a4),4(a1)
  4847.         move.l    #20,d0
  4848.         RELLIB    ComputeY,_KCXBase
  4849.         add.w    OffY(a5),d0
  4850.         move.l    d0,d1
  4851.         move.l    #502,d0
  4852.         DOLIB    ComputeX
  4853.         move.l    d0,d2
  4854.         move.l    #46,d0
  4855.         DOLIB    ComputeY
  4856.         move.l    d0,d3
  4857.         move.l    #2,d0
  4858.         DOLIB    ComputeX
  4859.         add.w    OffX(a5),d0
  4860.         RELLIB    DrawBevelBoxA,_GadToolsBase
  4861.  
  4862.         move.l    FormHandle(a4),a0
  4863.         suba.l    a1,a1
  4864.         DOLIB    GT_RefreshWindow
  4865.  
  4866.         bsr.s    SetFormGads
  4867.  
  4868.         move.l    -4(a5),a0
  4869.         RELLIB    ScreenToFront,_IntuitionBase
  4870.  
  4871.         bsr    UnlockScreen
  4872.         unlk    a5
  4873.         rts
  4874. .FormWinError    bsr    CloseFormWin
  4875.         move.l    #MEMORY_ERR,ErrorBack(a4)
  4876.         bsr    DisplayError
  4877.         bsr    UnlockScreen
  4878.         unlk    a5
  4879.         rts
  4880. FormBevelTag    dc.l    GT_VisualInfo,0,TAG_DONE
  4881.  
  4882.  
  4883.  
  4884. **********************************************************************
  4885. *                        Set Formatter gadget                        *
  4886. **********************************************************************
  4887. SetFormGads    move.b    MakeIcons(a4),d0
  4888.         move.l    #GD_Trashcan,d1
  4889.         bsr    SetFormBox
  4890.         move.b    QuickFormat(a4),d0
  4891.         move.l    #GD_Quick,d1
  4892.         bsr    SetFormBox
  4893.         move.b    FFSDrive(a4),d0
  4894.         move.l    #GD_FFS,d1
  4895.         bsr    SetFormBox
  4896.         move.b    NoVerify(a4),d0
  4897.         move.l    #GD_NoVerify,d1
  4898.         bsr    SetFormBox
  4899.         move.b    Install(a4),d0
  4900.         move.l    #GD_Install,d1
  4901.         bsr    SetFormBox
  4902.         move.b    EjectDrive(a4),d0
  4903.         move.l    #GD_Eject,d1
  4904.         bsr    SetFormBox
  4905.         move.b    WatchDisks(a4),d0
  4906.         move.l    #GD_WatchDisks,d1
  4907.         bsr    SetFormBox
  4908.         move.b    Watch0(a4),d0
  4909.         move.l    #GD_Watch0,d1
  4910.         bsr    SetFormBox
  4911.         move.b    Watch1(a4),d0
  4912.         move.l    #GD_Watch1,d1
  4913.         bsr    SetFormBox
  4914.         move.b    Watch2(a4),d0
  4915.         move.l    #GD_Watch2,d1
  4916.         bsr.s    SetFormBox
  4917.         move.b    Watch3(a4),d0
  4918.         move.l    #GD_Watch3,d1
  4919.         bsr.s    SetFormBox
  4920.         move.b    DirCache(a4),d0
  4921.         beq.s    .UseOldInt
  4922.         move.b    InterMode(a4),d0
  4923.         move.b    d0,OldInterMode(a4)
  4924.         moveq    #1,d0
  4925.         move.b    d0,InterMode(a4)
  4926.         moveq    #1,d2
  4927.         bra.s    .SetDirInt
  4928. .UseOldInt    move.b    OldInterMode(a4),d0
  4929.         move.b    d0,InterMode(a4)
  4930.         moveq    #0,d2
  4931. .SetDirInt    move.l    #GD_IntMode,d1
  4932.         bsr.s    SetFormBox
  4933.         move.l    #GD_IntMode,d0
  4934.         move.l    d2,d1
  4935.         RELLIB    GhostGadget,_KCXBase
  4936.         move.b    DirCache(a4),d0
  4937.         move.l    #GD_DiskCache,d1
  4938.         bsr.s    SetFormBox
  4939.  
  4940.         move.l    #GD_Drive,d0
  4941.         move.w    FormatDrive(a4),d1
  4942.         RELLIB    SetCycleGad,_KCXBase
  4943.  
  4944.         move.l    #GD_Label,d0
  4945.         lea    FormatDriveName(a4),a2
  4946.         DOLIB    SetStringGad
  4947.         rts
  4948. SetFormBox    lea    FormGads(a4),a0
  4949.         move.l    FormHandle(a4),a1
  4950.         RELLIB    SetCheckBox,_KCXBase
  4951.         rts
  4952.  
  4953.  
  4954.  
  4955. **********************************************************************
  4956. *                       Close formatter window                       *
  4957. **********************************************************************
  4958. CloseFormWin    lea    FormHandle(a4),a3
  4959.         bsr    CloseNormWindow
  4960.         clr.l    FormWinSig(a4)
  4961.         rts
  4962.  
  4963.  
  4964.  
  4965.  
  4966. **********************************************************************
  4967. *                        Open the bill window                        *
  4968. **********************************************************************
  4969. OpenBillWin    tst.l    BillHandle(a4)
  4970.         beq.s    .End
  4971.         move.l    BillHandle(a4),a0
  4972.         RELLIB    WindowToFront,_IntuitionBase
  4973.         rts
  4974. .End        link    a5,#-(4+4+2+2+2+2+gng_SIZEOF)    ; Try to lock public screen
  4975.         lea    BillTxt(a4),a0
  4976.         move.l    a0,FontPtr(a5)
  4977.         lea    PubScreenName(a4),a3        ; named in prefs
  4978. .FindScreen    tst.b    (a3)
  4979.         beq.s    .WBScreen
  4980.         move.l    a3,a2
  4981. .FindEnd    tst.b    (a2)
  4982.         beq.s    .GoOn
  4983.         cmp.b    #';',(a2)
  4984.         beq.s    .GoOn
  4985.         addq.l    #1,a2
  4986.         bra.s    .FindEnd
  4987. .GoOn        move.b    (a2),d6
  4988.         clr.b    (a2)
  4989.         move.l    a3,a0
  4990.         lea    BillPubScr(a4),a1
  4991.         bsr    StrCpy
  4992.         move.l    a3,a0
  4993.         RELLIB    LockPubScreen,_IntuitionBase
  4994.         move.l    d0,-4(a5)
  4995.         move.b    d6,(a2)
  4996.         tst.l    d0
  4997.         bne.s    .GotPubScreen
  4998. .FindNext    tst.b    (a3)
  4999.         beq.s    .WBScreen
  5000.         cmp.b    #';',(a3)+
  5001.         bne.s    .FindNext
  5002.         bra.s    .FindScreen
  5003.  
  5004. .WBScreen    sub.l    a0,a0                ; On error -> Try to lock WB
  5005.         RELLIB    LockPubScreen,_IntuitionBase
  5006.         move.l    d0,-4(a5)
  5007.         beq    .BillWinError
  5008.  
  5009. .GotPubScreen    moveq    #0,d2
  5010.         moveq    #0,d3
  5011.         RELLIB    ComputeFont,_KCXBase
  5012.         move.l    -4(a5),a0
  5013.         sub.l    a1,a1
  5014.         RELLIB    GetVisualInfoA,_GadToolsBase
  5015.         move.l    d0,BillVisInfo(a4)
  5016.         beq    .BillWinError
  5017.  
  5018.         move.l    -4(a5),a0
  5019.         moveq    #0,d3
  5020.         moveq    #0,d2
  5021.         move.b    sc_BarHeight(a0),d3
  5022.         addq.w    #1,d3
  5023.         move.w    d3,BillZoomSize+6(a4)
  5024.         move.w    BillWinWidth(a4),d2
  5025.         move.w    BillWinHeight(a4),d3
  5026.         RELLIB    ComputeFont,_KCXBase
  5027.         move.l    -4(a5),a0
  5028.         move.l    d2,d0
  5029.         DOLIB    ComputeX
  5030.         move.l    d0,d4
  5031.         move.w    BillWinLeft(a4),d2
  5032.         add.w    d2,d0
  5033.         add.w    OffX(a5),d0
  5034.         moveq    #0,d1
  5035.         move.b    sc_WBorRight(a0),d1
  5036.         add.w    d1,d0
  5037.         cmp.w    sc_Width(a0),d0
  5038.         bls.s    .WOk
  5039.         move.w    sc_Width(a0),d0
  5040.         sub.w    d4,d0
  5041.         move.w    d0,d2
  5042. .WOk        move.l    d3,d0
  5043.         DOLIB    ComputeY
  5044.         move.l    d0,d4
  5045.         move.w    BillWinTop(a4),d3
  5046.         add.w    d3,d0
  5047.         add.w    OffY(a5),d0
  5048.         moveq    #0,d1
  5049.         move.b    sc_WBorBottom(a0),d1
  5050.         add.w    d1,d0
  5051.         cmp.w    sc_Height(a0),d0
  5052.         bls.s    .HOk
  5053.         move.w    sc_Height(a0),d0
  5054.         sub.w    d4,d0
  5055.         move.w    d0,d3
  5056. .HOk        lea.l    BillGadget(a4),a0
  5057.         RELLIB    CreateContext,_GadToolsBase
  5058.         move.l    d0,a3
  5059.         beq    .BillWinError
  5060.  
  5061.         movem.l d2-d3/a4,-(sp)
  5062.         moveq    #0,d3
  5063.         lea.l    BillWinGTags,a4
  5064. .BillWinGL    lea.l    BillWinNGads,a0
  5065.         move.l    d3,d0
  5066.         mulu    #gng_SIZEOF,d0
  5067.         add.l    d0,a0
  5068.         lea.l    -(4+4+2+2+2+2+gng_SIZEOF)(a5),a1
  5069.         moveq    #gng_SIZEOF,d0
  5070.         CALLSYS    CopyMem
  5071.         lea.l    -(4+4+2+2+2+2+gng_SIZEOF)(a5),a0
  5072.         move.l    a4,-(sp)
  5073.         move.l    ZeroBase(pc),a4
  5074.         move.l    gng_GadgetText(a0),-(sp)
  5075.         bsr    GetLocStr
  5076.         move.l    (sp)+,d7
  5077.         move.l    d7,gng_GadgetText(a0)
  5078.         move.l    BillVisInfo(a4),gng_VisualInfo(a0)
  5079.         move.l    FontPtr(a5),gng_TextAttr(a0)
  5080.         move.w    gng_LeftEdge(a0),d0
  5081.         RELLIB    ComputeX,_KCXBase
  5082.         move.l    (sp)+,a4
  5083.         add.w    OffX(a5),d0
  5084.         move.w    d0,gng_LeftEdge(a0)
  5085.         move.w    gng_TopEdge(a0),d0
  5086.         DOLIB    ComputeY
  5087.         add.w    OffY(a5),d0
  5088.         move.w    d0,gng_TopEdge(a0)
  5089.         move.w    gng_Width(a0),d0
  5090.         DOLIB    ComputeX
  5091.         move.w    d0,gng_Width(a0)
  5092.         move.w    gng_Height(a0),d0
  5093.         DOLIB    ComputeY
  5094.         move.w    d0,gng_Height(a0)
  5095.         lea.l    BillWinGTypes,a0
  5096.         moveq    #0,d0
  5097.         move.l    d3,d1
  5098.         lsl.l    #1,d1
  5099.         move.w    0(a0,d1.w),d0
  5100.         move.l    a3,a0
  5101.         lea.l    -(4+4+2+2+2+2+gng_SIZEOF)(a5),a1
  5102.         move.l    a4,a2
  5103.         move.l    a4,-(sp)
  5104.         move.l    ZeroBase(pc),a4
  5105.         bsr    LocalizeGadTags
  5106.         RELLIB    CreateGadgetA,_GadToolsBase
  5107.         move.l    (sp)+,a4
  5108.         tst.l    d0
  5109.         beq    .BillWinError
  5110.         move.l    d0,a3
  5111.         move.l    d7,a0
  5112.         bsr    LocalizeGadKey
  5113.         move.l    d1,gg_UserData(a3)
  5114.         move.l    d3,d0
  5115.         lsl.l    #2,d0
  5116.         move.l    a4,-(sp)
  5117.         move.l    ZeroBase(pc),a4
  5118.         lea.l    BillGads(a4),a0
  5119.         move.l    (sp)+,a4
  5120.         move.l    a3,0(a0,d0.w)
  5121. .BillWinTL    tst.l    (a4)
  5122.         beq.s    .BillWinDN
  5123.         addq.w    #8,a4
  5124.         bra.s    .BillWinTL
  5125. .BillWinDN    addq.w    #4,a4
  5126.         addq.w    #1,d3
  5127.         cmp.w    #BillWin_CNT,d3
  5128.         bmi    .BillWinGL
  5129.         movem.l (sp)+,d2-d3/a4
  5130.         move.l    BillGadget(a4),BillWinWG+4
  5131.  
  5132.         LOCLEA    DefBillTitle,a0
  5133.         lea    BillTitle(a4),a1
  5134.         move.l    a1,BillWinWG+12
  5135.         bsr    StrCpy
  5136.         lea    BillHotKey(a4),a0
  5137.         lea    BillTitle(a4),a1
  5138.         bsr    StrCat
  5139.         LOCLEA    WindowScrTitle,BillWinWG+20
  5140.         move.l    -4(a5),BillWinSC+4        ; Open window
  5141.         ext.l    d2
  5142.         ext.l    d3
  5143.         move.l    d2,BillWinL+4
  5144.         move.l    d3,BillWinT+4
  5145.         move.l    -4(a5),a0
  5146.         move.w    BillWinWidth(a4),d0
  5147.         RELLIB    ComputeX,_KCXBase
  5148.         add.w    OffX(a5),d0
  5149.         moveq    #0,d1
  5150.         move.b    sc_WBorRight(a0),d1
  5151.         add.w    d1,d0
  5152.         move.l    d0,BillWinW+4
  5153.         move.w    d0,BillZoomSize+4(a4)
  5154.         move.w    BillWinHeight(a4),d0
  5155.         DOLIB    ComputeY
  5156.         add.w    OffY(a5),d0
  5157.         moveq    #0,d1
  5158.         move.b    sc_WBorBottom(a0),d1
  5159.         add.w    d1,d0
  5160.         move.l    d0,BillWinH+4
  5161.         suba.l    a0,a0
  5162.         tst.b    ActiveBill(a4)
  5163.         beq.s    .NoActiveBill
  5164.         or.l    #WFLG_ACTIVATE,BillWinF+4
  5165.         bra.s    .OpenBill
  5166. .NoActiveBill    and.l    #~WFLG_ACTIVATE,BillWinF+4
  5167. .OpenBill    lea.l    BillWinWindowTags,a1
  5168.         RELLIB    OpenWindowTagList,_IntuitionBase
  5169.         move.l    d0,BillHandle(a4)
  5170.         beq.s    .BillWinError
  5171.         move.l    d0,a0
  5172.         moveq    #0,d0
  5173.         moveq    #1,d1
  5174.         move.l    wd_UserPort(a0),a0
  5175.         move.b    MP_SIGBIT(a0),d0
  5176.         lsl.l    d0,d1
  5177.         move.l    d1,BillSigFlag(a4)
  5178.  
  5179.         move.l    BillHandle(a4),a0
  5180.         suba.l    a1,a1
  5181.         RELLIB    GT_RefreshWindow,_GadToolsBase
  5182.  
  5183.         bsr.s    SetBillGads
  5184.  
  5185.         tst.b    Zipped(a4)
  5186.         beq.s    .NoBillClose
  5187.         move.l    BillHandle(a4),a0
  5188.         RELLIB    ZipWindow,_IntuitionBase
  5189.         bsr    RemakeCosts
  5190.         bra.s    .NoBillClose
  5191.  
  5192. .BillWinError    bsr.s    CloseBillWin
  5193.         move.l    #MEMORY_ERR,ErrorBack(a4)
  5194.         bsr    DisplayError
  5195. .NoBillClose    bsr    UnlockScreen
  5196.         unlk    a5
  5197.         rts
  5198.  
  5199.  
  5200. **********************************************************************
  5201. *                       Set bill window gadget                       *
  5202. **********************************************************************
  5203. SetBillGads    move.l    #GD_LogCall,d1            ; Set LogCalls gadget
  5204.         lea    BillGads(a4),a0
  5205.         move.l    BillHandle(a4),a1
  5206.         moveq    #0,d0
  5207.         move.b    LogCalls(a4),d0
  5208.         RELLIB    SetCheckBox,_KCXBase
  5209.  
  5210.         move.l    #GD_BillTimeMX,d0
  5211.         move.l    TimeZone(a4),d1
  5212.         lea    BillGads(a4),a0
  5213.         move.l    BillHandle(a4),a1
  5214.         DOLIB    SetMXGad
  5215.  
  5216.         move.l    #GD_BillCheap,d0
  5217.         moveq    #0,d1
  5218.         move.b    CheapMode(a4),d1
  5219.         lea    BillGads(a4),a0
  5220.         move.l    BillHandle(a4),a1
  5221.         DOLIB    SetMXGad
  5222.         rts
  5223.  
  5224.  
  5225. **********************************************************************
  5226. *                       Close the bill window                        *
  5227. **********************************************************************
  5228. CloseBillWin    lea    BillHandle(a4),a3
  5229.         bra    CloseNormWindow
  5230.  
  5231.  
  5232.  
  5233.  
  5234.  
  5235. **********************************************************************
  5236. *                        Select a new screen                         *
  5237. **********************************************************************
  5238. OpenSelScrWin    tst.l    SelScrHandle(a4)
  5239.         beq.s    .GoOn
  5240.         move.l    SelScrHandle(a4),a0
  5241.         RELLIB    WindowToFront,_IntuitionBase
  5242.         rts
  5243. .GoOn        bsr    CollectScrs
  5244.         link    a5,#-(4+4+2+2+2+2+gng_SIZEOF)
  5245.         lea    SelScrTxt(a4),a0
  5246.         move.l    a0,FontPtr(a5)
  5247.  
  5248.         moveq    #0,d0
  5249.         RELLIB    LockIBase,_IntuitionBase
  5250.         move.l    d0,a0
  5251.         move.l    _IntuitionBase(a4),a2
  5252.         move.l    ib_ActiveScreen(a2),a2
  5253.         move.l    a2,LastSelectedScr(a4)
  5254.         DOLIB    UnlockIBase
  5255.         move.w    sc_Flags(a2),d0
  5256.         and.w    #SCREENTYPE,d0
  5257.         cmp.w    #PUBLICSCREEN,d0
  5258.         bne.s    .UseWB
  5259.         DOLIB    LockPubScreenList
  5260.         tst.l    d0
  5261.         beq.s    .UseWB
  5262.         move.l    d0,a3
  5263.         move.l    LH_HEAD(a3),a3
  5264. .GetPubScr    cmp.l    psn_Screen(a3),a2
  5265.         beq.s    .GotIt
  5266.         SUCC    a3,a3
  5267.         bra.s    .GetPubScr
  5268. .GotIt        link    a5,#-(MAXPUBSCREENNAME+1)
  5269.         move.l    LN_NAME(a3),a0
  5270.         lea    -(MAXPUBSCREENNAME+1)(a5),a1
  5271.         bsr    StrCpy
  5272.         DOLIB    UnlockPubScreenList
  5273.         lea    -(MAXPUBSCREENNAME+1)(a5),a0
  5274.         DOLIB    LockPubScreen
  5275.         unlk    a5
  5276.         move.l    d0,-4(a5)
  5277.         bra.s    .GotMyScr
  5278. .UseWB        bsr    LockScreen
  5279. .GotMyScr    tst.l    d0
  5280.         beq    .SelScrWinError
  5281.         move.l    d0,a0
  5282.         RELLIB    ScreenToFront,_IntuitionBase
  5283.         moveq    #0,d2
  5284.         moveq    #0,d3
  5285.         RELLIB    ComputeFont,_KCXBase
  5286.         move.l    -4(a5),a0
  5287.         sub.l    a1,a1
  5288.         RELLIB    GetVisualInfoA,_GadToolsBase
  5289.         move.l    d0,SelScrVisInfo(a4)
  5290.         beq    .SelScrWinError
  5291.  
  5292.         move.l    -4(a5),a0
  5293.         moveq    #0,d3
  5294.         moveq    #0,d2
  5295.         move.w    SelScrWinWidth(a4),d2
  5296.         move.w    SelScrWinHeight(a4),d3
  5297.         RELLIB    ComputeFont,_KCXBase
  5298.         move.l    -4(a5),a0
  5299.         move.l    d2,d0
  5300.         DOLIB    ComputeX
  5301.         move.l    d0,d4
  5302.         move.w    SelScrWinLeft(a4),d2
  5303.         move.l    -4(a5),a3
  5304.         move.w    sc_LeftEdge(a3),d5
  5305.         neg.w    d5
  5306.         add.w    d5,d2
  5307.         add.w    d2,d0
  5308.         add.w    OffX(a5),d0
  5309.         moveq    #0,d1
  5310.         move.b    sc_WBorRight(a0),d1
  5311.         add.w    d1,d0
  5312.         cmp.w    sc_Width(a0),d0
  5313.         bls.s    .WOk
  5314.         move.w    sc_Width(a0),d0
  5315.         sub.w    d4,d0
  5316.         move.w    d0,d2
  5317. .WOk        move.l    d3,d0
  5318.         DOLIB    ComputeY
  5319.         move.l    d0,d4
  5320.         move.w    SelScrWinTop(a4),d3
  5321.         move.l    -4(a5),a3
  5322.         move.w    sc_TopEdge(a3),d5
  5323.         neg.w    d5
  5324.         add.w    d5,d3
  5325.         add.w    d3,d0
  5326.         add.w    OffY(a5),d0
  5327.         moveq    #0,d1
  5328.         move.b    sc_WBorBottom(a0),d1
  5329.         add.w    d1,d0
  5330.         cmp.w    sc_Height(a0),d0
  5331.         bls.s    .HOk
  5332.         move.w    sc_Height(a0),d0
  5333.         sub.w    d4,d0
  5334.         move.w    d0,d3
  5335. .HOk        lea.l    SelScrGadget(a4),a0
  5336.         RELLIB    CreateContext,_GadToolsBase
  5337.         move.l    d0,a3
  5338.         beq    .SelScrWinError
  5339.  
  5340.         movem.l d2-d3/a4,-(sp)
  5341.         moveq    #0,d3
  5342.         lea.l    SelScrWinGTags,a4
  5343. .SelScrWinGL    lea.l    SelScrWinNGads,a0
  5344.         move.l    d3,d0
  5345.         mulu    #gng_SIZEOF,d0
  5346.         add.l    d0,a0
  5347.         lea.l    -(4+4+2+2+2+2+gng_SIZEOF)(a5),a1
  5348.         moveq    #gng_SIZEOF,d0
  5349.         CALLSYS    CopyMem
  5350.         lea.l    -(4+4+2+2+2+2+gng_SIZEOF)(a5),a0
  5351.         move.l    a4,-(sp)
  5352.         move.l    ZeroBase(pc),a4
  5353.         move.l    gng_GadgetText(a0),-(sp)
  5354.         bsr    GetLocStr
  5355.         move.l    (sp)+,d7
  5356.         move.l    d7,gng_GadgetText(a0)
  5357.         move.l    SelScrVisInfo(a4),gng_VisualInfo(a0)
  5358.         move.l    FontPtr(a5),gng_TextAttr(a0)
  5359.         move.w    gng_LeftEdge(a0),d0
  5360.         RELLIB    ComputeX,_KCXBase
  5361.         move.l    (sp)+,a4
  5362.         add.w    OffX(a5),d0
  5363.         move.w    d0,gng_LeftEdge(a0)
  5364.         move.w    gng_TopEdge(a0),d0
  5365.         DOLIB    ComputeY
  5366.         add.w    OffY(a5),d0
  5367.         move.w    d0,gng_TopEdge(a0)
  5368.         move.w    gng_Width(a0),d0
  5369.         DOLIB    ComputeX
  5370.         move.w    d0,gng_Width(a0)
  5371.         move.w    gng_Height(a0),d0
  5372.         DOLIB    ComputeY
  5373.         move.w    d0,gng_Height(a0)
  5374.         lea.l    SelScrWinGTypes,a0
  5375.         moveq    #0,d0
  5376.         move.l    d3,d1
  5377.         lsl.l    #1,d1
  5378.         move.w    0(a0,d1.w),d0
  5379.         move.l    a3,a0
  5380.         lea.l    -(4+4+2+2+2+2+gng_SIZEOF)(a5),a1
  5381.         move.l    a4,a2
  5382.         move.l    a4,-(sp)
  5383.         move.l    ZeroBase(pc),a4
  5384.         RELLIB    CreateGadgetA,_GadToolsBase
  5385.         move.l    (sp)+,a4
  5386.         tst.l    d0
  5387.         beq    .SelScrWinError
  5388.         move.l    d0,a3
  5389.         move.l    d7,a0
  5390.         bsr    LocalizeGadKey
  5391.         move.l    d1,gg_UserData(a3)
  5392.         move.l    d3,d0
  5393.         lsl.l    #2,d0
  5394.         move.l    a4,-(sp)
  5395.         move.l    ZeroBase(pc),a4
  5396.         lea.l    SelScrGads(a4),a0
  5397.         move.l    (sp)+,a4
  5398.         move.l    a3,0(a0,d0.w)
  5399. .SelScrWinTL    tst.l    (a4)
  5400.         beq.s    .SelScrWinDN
  5401.         addq.w    #8,a4
  5402.         bra.s    .SelScrWinTL
  5403. .SelScrWinDN    addq.w    #4,a4
  5404.         addq.w    #1,d3
  5405.         cmp.w    #SelectScrWin_CNT,d3
  5406.         bmi    .SelScrWinGL
  5407.         movem.l (sp)+,d2-d3/a4
  5408.         move.l    SelScrGadget(a4),SelScrWinWG+4
  5409.  
  5410.         LOCLEA    DefSelScrTitle,a0
  5411.         lea    SelScrTitle(a4),a1
  5412.         move.l    a1,SelScrWinWG+12
  5413.         bsr    StrCpy
  5414.         lea    SelScrHotKey(a4),a0
  5415.         lea    SelScrTitle(a4),a1
  5416.         bsr    StrCat
  5417.         LOCLEA    WindowScrTitle,SelScrWinWG+20
  5418.         move.l    -4(a5),SelScrWinSC+4        ; Open window
  5419.         ext.l    d2
  5420.         ext.l    d3
  5421.         move.l    d2,SelScrWinL+4
  5422.         move.l    d3,SelScrWinT+4
  5423.         move.l    -4(a5),a0
  5424.         move.w    SelScrWinWidth(a4),d0
  5425.         RELLIB    ComputeX,_KCXBase
  5426.         add.w    OffX(a5),d0
  5427.         moveq    #0,d1
  5428.         move.b    sc_WBorRight(a0),d1
  5429.         add.w    d1,d0
  5430.         move.l    d0,SelScrWinW+4
  5431.         move.w    SelScrWinHeight(a4),d0
  5432.         DOLIB    ComputeY
  5433.         add.w    OffY(a5),d0
  5434.         moveq    #0,d1
  5435.         move.b    sc_WBorBottom(a0),d1
  5436.         add.w    d1,d0
  5437.         move.l    d0,SelScrWinH+4
  5438.         suba.l    a0,a0
  5439.         lea.l    SelScrWinWindowTags,a1
  5440.         RELLIB    OpenWindowTagList,_IntuitionBase
  5441.         move.l    d0,SelScrHandle(a4)
  5442.         beq.s    .SelScrWinError
  5443.         move.l    d0,a0
  5444.         moveq    #0,d0
  5445.         moveq    #1,d1
  5446.         move.l    wd_UserPort(a0),a0
  5447.         move.b    MP_SIGBIT(a0),d0
  5448.         lsl.l    d0,d1
  5449.         move.l    d1,SelScrWinSig(a4)
  5450.  
  5451.         move.l    SelScrHandle(a4),a0
  5452.         suba.l    a1,a1
  5453.         RELLIB    GT_RefreshWindow,_GadToolsBase
  5454.  
  5455.         bsr    UnlockScreen
  5456.         unlk    a5
  5457.         move.l    SelScrHandle(a4),a0
  5458.         RELLIB    ActivateWindow,_IntuitionBase
  5459.         rts
  5460.  
  5461. .SelScrWinError    bsr.s    CloseSelScrWin
  5462.         move.l    #MEMORY_ERR,ErrorBack(a4)
  5463.         bsr    DisplayError
  5464.         bsr    UnlockScreen
  5465.         unlk    a5
  5466.         rts
  5467.  
  5468. CloseSelScrWin    lea    SelScrList(a4),a0
  5469.         tst.l    (a0)
  5470.         beq.s    .End
  5471.         RELLIB    FreeWindows,_KCXBase
  5472. .End        lea    SelScrHandle(a4),a3
  5473.         bsr.s    CloseNormWindow
  5474.         clr.l    SelScrWinSig(a4)
  5475.         rts
  5476. PubScrName    dc.b    "(PUB) ",0
  5477.         EVEN
  5478.  
  5479.  
  5480. **********************************************************************
  5481. *            Close down a window with a non-shared IDCMP             *
  5482. **********************************************************************
  5483. CloseNormWindow    tst.l    (a3)
  5484.         beq.s    .NoWindow
  5485.         move.l    (a3),a0
  5486.         RELLIB    CloseWindow,_IntuitionBase    ; Close Window
  5487. .NoWindow    tst.l    4(a3)
  5488.         beq.s    .NoGadgets
  5489.         move.l    4(a3),a0            ; Free GadTools-Gadgets
  5490.         RELLIB    FreeGadgets,_GadToolsBase
  5491. .NoGadgets    tst.l    8(a3)                ; Free Visual-Info
  5492.         beq.s    .NoVisInfo
  5493.         move.l    8(a3),a0
  5494.         RELLIB    FreeVisualInfo,_GadToolsBase
  5495. .NoVisInfo    clr.l    (a3)                ; Clear flags for later
  5496.         clr.l    4(a3)                ; identification
  5497.         clr.l    8(a3)
  5498.         rts
  5499.  
  5500.  
  5501.  
  5502.  
  5503. **********************************************************************
  5504. *                   Collect all available screens                    *
  5505. **********************************************************************
  5506. CollectScrs    link    a5,#-8
  5507.         moveq    #0,d0
  5508.         RELLIB    LockIBase,_IntuitionBase
  5509.         move.l    d0,-4(a5)
  5510.         DOLIB    LockPubScreenList
  5511.         move.l    d0,-8(a5)
  5512.  
  5513.         clr.w    NumScreens(a4)            ; Create Screen list
  5514.         clr.w    SelectedScreen(a4)
  5515.         lea    SelScrList(a4),a0
  5516.         NEWLIST    a0
  5517.  
  5518.         move.l    -8(a5),a2            ; Collect all PubScreens
  5519.         move.l    LH_HEAD(a2),a2
  5520.         TSTLIST    a2
  5521.         beq.s    .NoMorePubs
  5522. .GetPubScrs    tst.l    (a2)
  5523.         beq.s    .NoMorePubs
  5524.         move.l    #selscr_SIZEOF,d0
  5525.         move.l    #MEMF_CLEAR,d1
  5526.         CALLSYS    AllocVec
  5527.         tst.l    d0
  5528.         beq    .ErrorScrs
  5529.         lea    SelScrList(a4),a0
  5530.         move.l    d0,a1
  5531.         move.l    d0,a3
  5532.         ADDTAIL
  5533.         move.l    psn_Screen(a2),selscr_Address(a3)
  5534.         lea    PubScrName(pc),a0
  5535.         lea    selscr_Name(a3),a1
  5536.         move.l    a1,LN_NAME(a3)
  5537.         bsr    StrCpy
  5538.         move.l    LN_NAME(a2),a0
  5539.         lea    selscr_Name(a3),a1
  5540.         bsr    StrCat
  5541.         addq.w    #1,NumScreens(a4)
  5542.         SUCC    a2,a2
  5543.         bra.s    .GetPubScrs
  5544.  
  5545. .NoMorePubs    move.l    _IntuitionBase(a4),a2
  5546.         move.l    ib_FirstScreen(a2),a2
  5547. .GetNormScrs    move.l    a2,d0
  5548.         beq.s    .ErrorScrs
  5549.         move.w    sc_Flags(a2),d0
  5550.         and.w    #SCREENTYPE,d0
  5551.         cmp.w    #CUSTOMSCREEN,d0
  5552.         bne.s    .IsPubScr
  5553.         move.l    #selscr_SIZEOF,d0
  5554.         move.l    #MEMF_CLEAR,d1
  5555.         CALLSYS    AllocVec
  5556.         tst.l    d0
  5557.         beq.s    .ErrorScrs
  5558.         lea    SelScrList(a4),a0
  5559.         move.l    d0,a1
  5560.         move.l    d0,a3
  5561.         ADDTAIL
  5562.         move.l    a2,selscr_Address(a3)
  5563.         move.l    sc_Title(a2),d0
  5564.         bne.s    .GotAName
  5565.         LOCLEA    NoScrName,d0
  5566. .GotAName    move.l    d0,a0
  5567.         lea    selscr_Name(a3),a1
  5568.         move.l    a1,LN_NAME(a3)
  5569.         bsr    StrCpy
  5570.         addq.w    #1,NumScreens(a4)
  5571. .IsPubScr    move.l    sc_NextScreen(a2),a2
  5572.         bra.s    .GetNormScrs
  5573.  
  5574. .ErrorScrs    RELLIB    UnlockPubScreenList,_IntuitionBase
  5575.         move.l    -4(a5),a0
  5576.         DOLIB    UnlockIBase
  5577.         lea    DefPubScreenName(pc),a0
  5578.         DOLIB    GetDefaultPubScreen
  5579.         lea    SelScrList(a4),a0
  5580.         move.l    a0,SelScrWinGTags+4
  5581.         moveq    #0,d0
  5582.         move.w    NumScreens(a4),d0
  5583.         move.l    d0,ScrNumTag+4
  5584.         unlk    a5
  5585.         rts
  5586.  
  5587.  
  5588.  
  5589. **********************************************************************
  5590. *                    Close all remaining windows                     *
  5591. **********************************************************************
  5592. CloseWins    bsr    ClearTitleBar            ; Clear title bar
  5593.         bsr    CloseClockWin            ; Close clock window
  5594.         bsr    CloseFormWin
  5595.         bsr    CloseSelScrWin
  5596.         rts
  5597.  
  5598.  
  5599.  
  5600. **********************************************************************
  5601. *           Store new position of window within NewWindow            *
  5602. **********************************************************************
  5603. StoreWinPos    move.w    wd_LeftEdge(a0),0(a1)
  5604.         move.w    wd_TopEdge(a0),2(a1)
  5605.         rts
  5606.  
  5607.  
  5608.  
  5609. **********************************************************************
  5610. *                        Compare two strings                         *
  5611. **********************************************************************
  5612. StrCmp        movem.l    a0/a1,-(sp)            ; Store pointers
  5613. .Loop        moveq    #0,d0
  5614.         move.b    (a1)+,d0
  5615.         bsr    GetUpperCase
  5616.         move.b    d0,d1
  5617.         moveq    #0,d0
  5618.         move.b    (a0)+,d0            ; get chars
  5619.         bsr    GetUpperCase
  5620.         tst.b    d0                ; Source string ended ?
  5621.         beq.s    .EndSrc                ; yep -> final check
  5622.         cmp.b    #$0a,d0                ; a newline ?
  5623.         beq.s    .EndSrc                ; yep -> final check
  5624.         cmp.b    d0,d1                ; equal ?
  5625.         bne.s    .Invalid
  5626.         dbf    d7,.Loop
  5627.         movem.l    (sp)+,a0/a1
  5628.         moveq    #0,d0
  5629.         rts
  5630. .Invalid    moveq    #1,d0                ; Error flag
  5631.         movem.l    (sp)+,a0/a1
  5632.         rts
  5633. .EndSrc        cmp.b    d0,d1                ; last chars equal ?
  5634.         bne.s    .Invalid            ; Nope -> error
  5635.         moveq    #0,d0                ; a ok
  5636.         movem.l    (sp)+,a0/a1
  5637.         rts
  5638.  
  5639.  
  5640. **********************************************************************
  5641. *               Compare two strings (case sensitive)                 *
  5642. **********************************************************************
  5643. StrCmp2        moveq    #0,d0
  5644.         moveq    #0,d1
  5645.         movem.l    a0/a1,-(sp)            ; Store pointers
  5646. .Loop        move.b    (a0)+,d0            ; get chars
  5647.         move.b    (a1)+,d1
  5648.         tst.b    d0                ; Source string ended ?
  5649.         beq.s    .EndSrc                ; yep -> final check
  5650.         cmp.b    #$0a,d0                ; a newline ?
  5651.         beq.s    .EndSrc                ; yep -> final check
  5652.         cmp.b    d0,d1                ; equal ?
  5653.         bne.s    .Invalid
  5654.         dbf    d7,.Loop
  5655.         movem.l    (sp)+,a0/a1
  5656.         moveq    #0,d0
  5657.         rts
  5658. .Invalid    moveq    #1,d0                ; Error flag
  5659.         movem.l    (sp)+,a0/a1
  5660.         rts
  5661. .EndSrc        cmp.b    d0,d1                ; last chars equal ?
  5662.         bne.s    .Invalid            ; Nope -> error
  5663.         moveq    #0,d0                ; a ok
  5664.         movem.l    (sp)+,a0/a1
  5665.         rts
  5666.  
  5667. **********************************************************************
  5668. *                           Copy a string                            *
  5669. **********************************************************************
  5670. StrCpy        move.b    (a0)+,d0
  5671.         move.b    d0,(a1)+
  5672.         tst.b    d0
  5673.         beq.s    .End
  5674.         bra.s    StrCpy
  5675. .End        rts
  5676.  
  5677.  
  5678.  
  5679. **********************************************************************
  5680. *                          Concat 2 string                           *
  5681. **********************************************************************
  5682. StrCat        tst.b    (a1)+
  5683.         beq.s    .Loop
  5684.         bra    StrCat
  5685. .Loop        subq.l    #1,a1
  5686.         bra    StrCpy
  5687.  
  5688.  
  5689.  
  5690. **********************************************************************
  5691. *            Copy a string up to x chars or end of string            *
  5692. **********************************************************************
  5693. StrNCpy        move.b    (a0)+,d0
  5694.         move.b    d0,(a1)+
  5695.         tst.b    d0
  5696.         beq.s    .End
  5697.         dbf    d7,StrNCpy
  5698. .End        rts
  5699.  
  5700.  
  5701.  
  5702. **********************************************************************
  5703. *                      Calc length of a string                       *
  5704. **********************************************************************
  5705. StrLen        move.l    a0,-(sp)
  5706.         moveq    #0,d0
  5707. .Loop        tst.b    (a0)+
  5708.         beq.s    .End
  5709.         addq.w    #1,d0
  5710.         bne.s    .Loop
  5711. .End        move.l    (sp)+,a0
  5712.         rts
  5713.  
  5714.  
  5715.  
  5716. **********************************************************************
  5717. *           This part removes all waiting msgs for a port            *
  5718. **********************************************************************
  5719. KillMessages    CARGS    #0,.Wnd.L,.Port.L,.Base.L
  5720.         movem.l    a0/a1/a6,-(sp)            ; Store pointers
  5721. .Loop        move.l    .Port(sp),a0            ; Get pointer to port
  5722.         CALLSYS    GetMsg
  5723.         tst.l    d0
  5724.         beq.s    NoMoreMsgs
  5725.         move.l    d0,a1                ; Reply msg
  5726.         DOLIB    ReplyMsg
  5727.         bra    .Loop
  5728. NoMoreMsgs    movem.l    (sp)+,a0/a1/a6            ; Reget pointers
  5729.         rts
  5730.  
  5731.  
  5732.  
  5733.  
  5734. **********************************************************************
  5735. *                 String/Integer Gadget pens setten                  *
  5736. **********************************************************************
  5737. SetStrIntGads    movem.l    RegsAll,-(sp)
  5738.  
  5739. .Loop        move.l    (a0),d0
  5740.         beq.s    .End
  5741.         move.l    (a0)+,a1
  5742.         move.w    gg_GadgetType(a1),d0
  5743.         and.w    #GTYP_STRGADGET,d0
  5744.         beq.s    .NoStrGad
  5745.         move.l    gg_SpecialInfo(a1),a1
  5746.         move.l    si_Extension(a1),a1
  5747.         move.w    #$0102,sex_ActivePens(a1)
  5748. .NoStrGad    bra.s    .Loop
  5749. .End        movem.l    (sp)+,RegsAll
  5750.         rts
  5751.  
  5752.  
  5753. **********************************************************************
  5754. *                     Lock the Workbench-Screen                      *
  5755. **********************************************************************
  5756. LockScreen    lea    WBScrName(pc),a0
  5757.         RELLIB    LockPubScreen,_IntuitionBase
  5758.         move.l    d0,-4(a5)
  5759.         rts
  5760. WBScrName    dc.b    "Workbench",0
  5761.         EVEN
  5762.  
  5763.  
  5764. **********************************************************************
  5765. *                      Unlock the locked screen                      *
  5766. **********************************************************************
  5767. UnlockScreen    tst.l    -4(a5)
  5768.         beq.s    .End
  5769.         sub.l    a0,a0
  5770.         move.l    -4(a5),a1
  5771.         RELLIB    UnlockPubScreen,_IntuitionBase
  5772. .End        rts
  5773.  
  5774.  
  5775.  
  5776. **********************************************************************
  5777. *                         Lock our semaphore                         *
  5778. **********************************************************************
  5779. GetSemaphore    movem.l    a0/a6,-(sp)
  5780.         move.l    ZeroBase(pc),a0
  5781.         lea    MySemaphore(a0),a0
  5782.         CALLSYS    ObtainSemaphore
  5783.         movem.l    (sp)+,a0/a6
  5784.         rts
  5785.  
  5786.  
  5787.  
  5788. **********************************************************************
  5789. *                       Unlock semaphore again                       *
  5790. **********************************************************************
  5791. FreeSemaphore    movem.l    a0/a6,-(sp)
  5792.         move.l    ZeroBase(pc),a0
  5793.         lea    MySemaphore(a0),a0
  5794.         CALLSYS    ReleaseSemaphore
  5795.         movem.l    (sp)+,a0/a6
  5796.         rts
  5797.  
  5798.  
  5799.  
  5800. **********************************************************************
  5801. *                    Get a string from a locale                      *
  5802. **********************************************************************
  5803. GetLocStr    movem.l    d0-d1/a0-a1/a6,-(sp)
  5804.         move.l    MyCatalog,d1
  5805.         beq.s    .End
  5806.         move.l    24(sp),d0
  5807.         beq.s    .End
  5808.         move.l    d0,a1
  5809.         moveq    #0,d0
  5810.         move.l    a1,d1
  5811.         lea    LOCALE_END(pc),a0
  5812.         cmp.l    a0,d1
  5813.         bgt.s    .End
  5814.         lea    LOCALE_START(pc),a0
  5815.         cmp.l    a0,d1
  5816.         blt.s    .End
  5817.         sub.l    a0,d1
  5818.         beq.s    .GetIt
  5819. .Loop        tst.b    (a0)+
  5820.         bne.s    .Ok
  5821.         addq.l    #1,d0
  5822. .Ok        subq.l    #1,d1
  5823.         bne.s    .Loop
  5824.  
  5825. .GetIt        move.l    MyCatalog,a0
  5826.         RELLIB    GetCatalogStr,_LocaleBase
  5827.         move.l    d0,24(sp)
  5828. .End        movem.l    (sp)+,d0-d1/a0-a1/a6
  5829.         rts
  5830.  
  5831.  
  5832. **********************************************************************
  5833. *                    Localize a gadget`s shortcut                    *
  5834. *  A0 = Pointer to text                                              *
  5835. *  RETURN :                                                          *
  5836. *  D1 = Shortcut                                                     *
  5837. **********************************************************************
  5838. LocalizeGadKey    move.l    d0,-(sp)
  5839.         moveq    #0,d1
  5840.         move.l    a0,d2
  5841.         beq.s    .End
  5842. .GetShort    move.b    (a0)+,d2
  5843.         beq.s    .End
  5844.         cmp.b    #'_',d2
  5845.         bne.s    .GetShort
  5846.         moveq    #0,d0
  5847.         move.b    (a0),d0
  5848.         bsr    GetUpperCase
  5849.         move.l    d0,d1
  5850. .End        move.l    (sp)+,d0
  5851.         rts
  5852.  
  5853.  
  5854.  
  5855. **********************************************************************
  5856. *         Localizes tags of a ListView, Cycle and MX gadget          *
  5857. * D0 = Type of Gadget                                                *
  5858. * A2 = Pointer to TagList                                            *
  5859. **********************************************************************
  5860. LocalizeGadTags    movem.l    RegsAll,-(sp)
  5861.         cmp.w    #MX_KIND,d0
  5862.         bne.s    .NoCycle
  5863.         move.l    #GTMX_Labels,d0
  5864.         move.l    a2,a0
  5865.         RELLIB    FindTagItem,_UtilityBase
  5866.         tst.l    d0
  5867.         beq.s    .End
  5868.         move.l    d0,a2
  5869.         move.l    ti_Data(a2),a2
  5870. .PatchCycles    move.l    (a2),d0
  5871.         beq.s    .End
  5872.         move.l    d0,-(sp)
  5873.         bsr    GetLocStr
  5874.         move.l    (sp)+,(a2)
  5875.         addq.l    #4,a2
  5876.         bra.s    .PatchCycles
  5877. .NoCycle
  5878. .End        movem.l    (sp)+,RegsAll
  5879.         rts
  5880.  
  5881.  
  5882.  
  5883. **********************************************************************
  5884. *                   Open clock window. Width in D6                   *
  5885. **********************************************************************
  5886. OpenClockWin    add.w    #DEPTHWIDTH*2+8,d6        ; approximate width of close/depth gadgets
  5887.         ext.l    d6
  5888.         move.l    d6,ClockWidth            ; Store for compare
  5889.  
  5890.         tst.l    ClockHandle(a4)            ; Window already open ?
  5891.         bne.s    ClockWinOpen
  5892.  
  5893.         bsr    ClearTitleBar            ; Clear titlebar first
  5894.  
  5895.         link    a5,#-4
  5896.         bsr    LockScreen
  5897.         tst.l    d0
  5898.         beq    ClockError
  5899.  
  5900.         sub.l    a0,a0                ; Open clock window
  5901.         move.l    -4(a5),a1
  5902.         moveq    #0,d1
  5903.         move.b    sc_WBorTop(a1),d1
  5904.         moveq    #0,d0
  5905.         moveq    #0,d1
  5906.         move.w    ClockWinLeft(a4),d0
  5907.         move.w    ClockWinTop(a4),d1
  5908.         move.l    d0,ClockLeft
  5909.         move.l    d1,ClockTop
  5910.         lea    ClockWindowTags,a1
  5911.         RELLIB    OpenWindowTagList,_IntuitionBase
  5912.         move.l    d0,ClockHandle(a4)
  5913.         bne.s    GotClockWin
  5914.         clr.b    ClockWin(a4)            ; On failure close
  5915.         bra.s    ClockError
  5916. GotClockWin    move.l    ClockHandle(a4),a0        ; Get sig flag
  5917.         moveq    #0,d0
  5918.         move.l    wd_UserPort(a0),a0
  5919.         move.b    MP_SIGBIT(a0),d0
  5920.         moveq    #1,d1
  5921.         lsl.l    d0,d1
  5922.         move.l    d1,ClockSigFlag(a4)
  5923.         bsr    UnlockScreen
  5924.         unlk    a5
  5925. ClockWinOpen    move.l    ClockHandle(a4),a0        ; Current width not equal
  5926.         moveq    #0,d0                ; to width needed
  5927.         moveq    #0,d1
  5928.         moveq    #0,d2
  5929.         moveq    #0,d3
  5930.         move.w    wd_LeftEdge(a0),d0
  5931.         move.w    wd_TopEdge(a0),d1
  5932.         move.l    ClockWidth,d2
  5933.         cmp.w    wd_Width(a0),d2
  5934.         beq.s    CWidthOk
  5935.         moveq    #0,d3
  5936.         move.b    wd_BorderTop(a0),d3
  5937.         RELLIB    ChangeWindowBox,_IntuitionBase    ; so readjust width
  5938.         bsr    ClockRemake            ; Wait until window has been remade
  5939. CWidthOk    moveq    #1,d0
  5940.         rts
  5941. ClockError    bsr    UnlockScreen
  5942.         moveq    #0,d0
  5943.         unlk    a5
  5944.         rts
  5945.  
  5946.  
  5947.  
  5948. **********************************************************************
  5949. *                Close clockwindow and remove pointer                *
  5950. **********************************************************************
  5951. GD_DisplayWin                          EQU    1
  5952. CloseClockWin    tst.l    ClockHandle(a4)
  5953.         beq.s    .NoCWOpen
  5954.         move.l    ClockHandle(a4),a0        ; Store new coords in structure
  5955.         RELLIB    CloseWindow,_IntuitionBase    ; and now....CLOSE IT
  5956.         clr.l    ClockHandle(a4)
  5957.         clr.l    ClockSigFlag(a4)
  5958. .NoCWOpen    rts
  5959.  
  5960.  
  5961.  
  5962.  
  5963. **********************************************************************
  5964. *          This is the routine to handle RAW-Event actions           *
  5965. **********************************************************************
  5966. RawEventAction    movem.l    RegsAll,-(sp)
  5967.  
  5968.         move.l    a1,a4
  5969.         move.l    a0,IEvent(a4)
  5970.  
  5971. EventLoop    move.l    IEvent(a4),a0
  5972.         moveq    #0,d0
  5973.         move.b    ie_Class(a0),d0
  5974.         move.w    d0,IEClass(a4)            ; Store class
  5975.  
  5976.         tst.b    Disabled(a4)
  5977.         bne.s    .NoJoy
  5978.         opt    NOCHKIMM
  5979.         move.w    $dff00c,d0            ; I believe, a dirty code to check the JoyStick :)
  5980.         opt    CHKIMM
  5981.         btst    #1,d0
  5982.         bne.s    .Joy
  5983.         btst    #9,d0
  5984.         bne.s    .Joy
  5985.         move.w    d0,d1
  5986.         lsr.w    #1,d1
  5987.         eor.w    d0,d1
  5988.         btst    #0,d1
  5989.         bne.s    .Joy
  5990.         btst    #8,d1
  5991.         beq.s    .NoJoy
  5992. .Joy        tst.b    ScrTimeOut(a4)
  5993.         beq.s    .NoScr
  5994.         move.l    IEvent(a4),a0
  5995.         move.l    #REQ_ONSCREEN,d0
  5996.         bsr    SendEvent
  5997. .NoScr        SF    ScrTimeOut(a4)
  5998.         move.l    IEvent(a4),a0
  5999.         bsr    ResetTimer
  6000.  
  6001. .NoJoy        tst.b    Disabled(a4)
  6002.         bne.s    .NoLeftyAll
  6003.         tst.b    LeftyMouse(a4)            ; We have to swap Buttonqualifiers
  6004.         beq.s    .NoLeftyAll            ; for every message if needed
  6005.         move.l    IEvent(a4),a0
  6006.         move.w    ie_Qualifier(a0),d0        ; Change qualifiers for all events
  6007.         move.w    d0,d1
  6008.         btst    #IEQUALIFIERB_RBUTTON,d1
  6009.         beq.s    .NoRight
  6010.         bset    #IEQUALIFIERB_LEFTBUTTON,d0
  6011.         beq.s    .CheckLeft
  6012. .NoRight    bclr    #IEQUALIFIERB_LEFTBUTTON,d0
  6013. .CheckLeft    btst    #IEQUALIFIERB_LEFTBUTTON,d1
  6014.         beq.s    .NoLeft
  6015.         bset    #IEQUALIFIERB_RBUTTON,d0
  6016.         beq.s    .SaveQual
  6017. .NoLeft        bclr    #IEQUALIFIERB_RBUTTON,d0
  6018. .SaveQual    move.w    d0,ie_Qualifier(a0)
  6019.  
  6020. .NoLeftyAll    cmp.w    #IECLASS_RAWKEY,IEClass(a4)    ; Work on RawKeys and RawMous
  6021.         beq.s    .DoSpec                ; as well
  6022.         cmp.w    #IECLASS_RAWMOUSE,IEClass(a4)
  6023.         bne    NoSpec
  6024.  
  6025. .DoSpec        move.l    IEvent(a4),a0
  6026.         bsr    ResetTimer
  6027.  
  6028.         tst.b    Disabled(a4)            ; Swap for LeftyMouse
  6029.         bne.s    .CheckCycle
  6030.         tst.b    LeftyMouse(a4)
  6031.         beq.s    .CheckCycle
  6032.         move.l    IEvent(a4),a0
  6033.         move.w    ie_Code(a0),d0
  6034.         move.w    d0,d1
  6035.         and.w    #~IECODE_UP_PREFIX,d0
  6036.         cmp.w    #IECODE_LBUTTON,d0
  6037.         beq.s    .SwapThem
  6038.         cmp.w    #IECODE_RBUTTON,d0
  6039.         bne.s    .CheckCycle
  6040. .SwapThem    eor.w    #1,d1
  6041.         move.w    d1,ie_Code(a0)
  6042.  
  6043. .CheckCycle    cmp.w    #IECLASS_RAWMOUSE,IEClass(a4)    ; Mouse movement ?
  6044.         bne    .NoHold
  6045.  
  6046.         tst.b    Disabled(a4)
  6047.         bne.s    .NoYAcc
  6048.         tst.b    MouseAccel(a4)            ; Accelerate mouse ?
  6049.         beq.s    .NoYAcc
  6050.         move.l    IEvent(a4),a3
  6051.         move.w    ie_X(a3),d4            ; Get current X Position of mouse
  6052.         ext.l    d4
  6053.         moveq    #1,d5                ; Get direction to be moved
  6054.         tst.l    d4
  6055.         bge.s    .XBig
  6056.         neg.l    d4                ; Make position positive
  6057.         moveq    #-1,d5                ; And invert direction
  6058. .XBig        cmp.l    ThresHold(a4),d4        ; Check for threshold
  6059.         ble.s    .NoXAcc
  6060.         move.l    d4,d0
  6061.         sub.l    ThresHold(a4),d0        ; Sub threshold
  6062.         move.l    Accelerate(a4),d1        ; Accelerate
  6063.         RELLIB    SMult32,_UtilityBase
  6064.         move.l    d5,d1                ; Now for the direction
  6065.         DOLIB    SMult32
  6066.         move.w    d0,ie_X(a3)
  6067.  
  6068. .NoXAcc        move.w    ie_Y(a3),d4            ; Do the same for Y Position
  6069.         ext.l    d4
  6070.         moveq    #1,d5
  6071.         tst.l    d4
  6072.         bge.s    .YBig
  6073.         neg.l    d4
  6074.         moveq    #-1,d5
  6075. .YBig        cmp.l    ThresHold(a4),d4        ; Check for threshold
  6076.         ble.s    .NoYAcc
  6077.         move.l    d4,d0
  6078.         sub.l    ThresHold(a4),d0        ; Sub threshold
  6079.         move.l    Accelerate(a4),d1        ; Acceleration
  6080.         RELLIB    SMult32,_UtilityBase
  6081.         move.l    d5,d1
  6082.         DOLIB    SMult32
  6083.         move.w    d0,ie_Y(a3)
  6084.  
  6085. .NoYAcc        tst.b    Disabled(a4)
  6086.         bne.s    .NoHold
  6087.         tst.b    HoldMouse(a4)            ; Ready to hold mouse ???
  6088.         beq.s    .NoHold
  6089.  
  6090.         move.l    IEvent(a4),a2            ; Check for "Hold" keys
  6091.         move.w    ie_Qualifier(a2),d1
  6092.         move.w    d1,d0
  6093.         and.w    HoldXQual(a4),d0        ; Hold qualifier pressed ?
  6094.         cmp.w    HoldXQual(a4),d0
  6095.         bne.s    .NoVertHold
  6096.         clr.w    ie_X(a2)            ; Clear delta-movement
  6097. .NoVertHold    and.w    HoldYQual(a4),d1
  6098.         cmp.w    HoldYQual(a4),d1
  6099.         bne.s    .NoHold
  6100.         clr.w    ie_Y(a2)
  6101.  
  6102. .NoHold        tst.b    GfxGetting(a4)            ; Printer process getting new area ?
  6103.         beq.s    .NoGfxGetting
  6104.         cmp.w    #IECLASS_RAWMOUSE,IEClass(a4)
  6105.         bne.s    .NoGfxGetting
  6106.         move.l    IEvent(a4),a0
  6107.         move.w    ie_Code(a0),d0
  6108.         move.w    ie_Qualifier(a0),d1
  6109.         move.w    d1,d3
  6110.         and.w    #~(IEQUALIFIER_REPEAT|IEQUALIFIER_NUMERICPAD|IEQUALIFIER_INTERRUPT|IEQUALIFIER_RELATIVEMOUSE|IEQUALIFIER_MULTIBROADCAST),d1
  6111.         bsr    FilterDouble
  6112.         cmp.w    #IECODE_LBUTTON,d0
  6113.         beq.s    .LButton
  6114.         cmp.w    #IECODE_RBUTTON,d0
  6115.         beq.s    .RButton
  6116.         tst.w    d0
  6117.         move.l    #SIGMOUSE,d0
  6118.         bra.s    .SendSig2
  6119. .LButton    move.l    #SIGLBUTTON,d0
  6120.         bra.s    .SendSig
  6121. .RButton    move.l    #SIGRBUTTON,d0
  6122. .SendSig    clr.b    ie_Class(a0)
  6123. .SendSig2    move.l    PrintProc(a4),a1
  6124.         CALLSYS    Signal
  6125.         bra    NoTimerEvent
  6126.  
  6127. .NoGfxGetting    tst.b    ImDragging(a4)            ; Full dragging mode
  6128.         beq.s    .NoDragging
  6129.         cmp.w    #IECLASS_RAWMOUSE,IEClass(a4)
  6130.         bne.s    .NoDragging
  6131.         move.l    IEvent(a4),a0
  6132.         move.w    ie_Code(a0),d0
  6133.         move.w    ie_Qualifier(a0),d1
  6134.         and.w    #~(IEQUALIFIER_REPEAT|IEQUALIFIER_NUMERICPAD|IEQUALIFIER_INTERRUPT|IEQUALIFIER_RELATIVEMOUSE|IEQUALIFIER_MULTIBROADCAST),d1
  6135.         bsr    FilterDouble
  6136.         btst    #10,$dff016
  6137.         beq.s    .EndDrag
  6138.         cmp.w    #IECODE_LBUTTON|IECODE_UP_PREFIX,d0
  6139.         beq.s    .EndDrag
  6140.         move.l    #SIGMOUSE,d0
  6141.         bra.s    .SigDrag
  6142. .EndDrag    move.l    #SIGLBUTTON,d0
  6143. .SigDrag    move.l    BackTask(a4),a1
  6144.         CALLSYS    Signal
  6145.         bra    NoTimerEvent
  6146.  
  6147. .NoDragging    tst.b    GetSource(a4)            ; Printer process looking for new source ?
  6148.         beq.s    .NoGetSource
  6149.         cmp.w    #IECLASS_RAWMOUSE,IEClass(a4)
  6150.         bne.s    .NoGetSource
  6151.         move.l    IEvent(a4),a0
  6152.         move.w    ie_Code(a0),d0
  6153.         move.w    ie_Qualifier(a0),d1
  6154.         and.w    #~(IEQUALIFIER_REPEAT|IEQUALIFIER_NUMERICPAD|IEQUALIFIER_INTERRUPT|IEQUALIFIER_RELATIVEMOUSE|IEQUALIFIER_MULTIBROADCAST),d1
  6155.         bsr    FilterDouble
  6156.         cmp.w    #IECODE_LBUTTON,d0
  6157.         bne.s    .NoNewWin
  6158.         clr.b    ie_Class(a0)
  6159.         move.l    #SIGLBUTTON,d0
  6160.         move.l    PrintProc(a4),a1
  6161.         CALLSYS    Signal
  6162.         bra    NoTimerEvent
  6163.  
  6164. .NoGetSource    tst.b    GetNewWindow(a4)        ; Getting new window for lock ?
  6165.         beq.s    .NoNewWin
  6166.         cmp.w    #IECLASS_RAWMOUSE,IEClass(a4)
  6167.         bne.s    .NoNewWin
  6168.         move.l    IEvent(a4),a0
  6169.         move.w    ie_Code(a0),d0
  6170.         move.w    ie_Qualifier(a0),d1
  6171.         move.w    d1,d3
  6172.         and.w    #~(IEQUALIFIER_REPEAT|IEQUALIFIER_NUMERICPAD|IEQUALIFIER_INTERRUPT|IEQUALIFIER_RELATIVEMOUSE|IEQUALIFIER_MULTIBROADCAST),d1
  6173.         bsr    FilterDouble
  6174.         cmp.w    #IECODE_LBUTTON,d0
  6175.         bne.s    .NoNewWin
  6176.         clr.b    ie_Class(a0)
  6177.         move.l    #SIGLBUTTON,d0
  6178.         move.l    PrefsTask(a4),a1
  6179.         CALLSYS    Signal
  6180.         bra    NoTimerEvent
  6181.  
  6182. .NoNewWin    tst.b    Disabled(a4)
  6183.         bne    .NoCycle
  6184.         tst.b    CycleWin(a4)            ; Are we to cycle windows ?
  6185.         beq    .NoCycle
  6186.         move.l    IEvent(a4),a0
  6187.         move.w    ie_Code(a0),d0
  6188.         move.w    d0,d1
  6189.         and.w    #IECODE_UP_PREFIX,d1
  6190.         bne    .NoCycle
  6191.         move.w    ie_Qualifier(a0),d1
  6192.         and.w    #~(IEQUALIFIER_REPEAT|IEQUALIFIER_NUMERICPAD|IEQUALIFIER_INTERRUPT|IEQUALIFIER_RELATIVEMOUSE|IEQUALIFIER_MULTIBROADCAST),d1
  6193.         bsr    FilterDouble
  6194.         move.w    d1,d3
  6195.         cmp.w    BackCode(a4),d0            ; Check for Back key
  6196.         bne.s    .NotBack
  6197.         cmp.w    BackQual(a4),d1
  6198.         bne.s    .NotBack
  6199.         cmp.w    #1,BackClicks(a4)
  6200.         beq.s    .IsFront
  6201.         cmp.w    #1,ThisBackClick(a4)
  6202.         bne    .EndCycle
  6203.         bra.s    .IsFront
  6204. .NotBack    cmp.w    #IECODE_MBUTTON,d0
  6205.         bne.s    .NotMiddle
  6206.         cmp.w    MiddleQual(a4),d1
  6207.         bne.s    .NotMiddle
  6208.         cmp.w    #1,MiddleClicks(a4)
  6209.         beq.s    .IsFront
  6210.         cmp.w    #1,ThisMiddleClick(a4)
  6211.         bne.s    .EndCycle
  6212.         bra.s    .IsFront
  6213. .NotMiddle    cmp.w    FrontCode(a4),d0        ; Check for Front key
  6214.         bne.s    .NoCycling
  6215.         cmp.w    FrontQual(a4),d1
  6216.         bne.s    .NoCycling
  6217.         cmp.w    #1,FrontClicks(a4)
  6218.         beq.s    .IsFront
  6219.         cmp.w    #1,ThisFrontClick(a4)
  6220.         bne.s    .EndCycle
  6221. .IsFront    cmp.w    #IECLASS_RAWKEY,IEClass(a4)
  6222.         beq.s    .Clear
  6223.         cmp.w    #IECODE_RBUTTON,d0
  6224.         beq.s    .Clear
  6225.         cmp.w    #IECODE_MBUTTON,d0
  6226.         bne.s    .EndCycle
  6227. .Clear        clr.b    ie_Class(a0)            ; Clear event
  6228.         and.w    #IEQUALIFIER_LEFTBUTTON,d3    ; Left button pressed
  6229.         beq.s    .EndCycle
  6230.         move.l    ie_EventAddress(a0),d2        ; WB windows won`t take this combination
  6231.         link    a5,#-ie_SIZEOF
  6232.         lea    -ie_SIZEOF(a5),a0
  6233.         clr.l    ie_NextEvent(a0)        ; Send LeftButtonUp, so that
  6234.         move.b    #IECLASS_RAWMOUSE,ie_Class(a0)
  6235.         clr.b    ie_SubClass(a0)
  6236.         move.w    #IECODE_LBUTTON|IECODE_UP_PREFIX,ie_Code(a0)
  6237.         clr.w    ie_Qualifier(a0)
  6238.         move.l    d2,ie_EventAddress(a0)
  6239.         LNKLIB    AddIEvents,_CxBase        ; Add events
  6240.         unlk    a5
  6241. .EndCycle    move.l    IEvent(a4),a0
  6242.         move.l    #REQ_CYCLE,d0
  6243.         bsr    SendEvent
  6244.         ST    Cycled(a4)
  6245.         bra.s    .NoCycle
  6246. .NoCycling    SF    Cycled(a4)
  6247.  
  6248. .NoCycle    tst.b    Disabled(a4)
  6249.         bne.s    NoSpec
  6250.         tst.b    FullDrag(a4)            ; Full drag a window ?
  6251.         beq.s    NoSpec
  6252.         move.l    IEvent(a4),a0            ; Check for qualifier
  6253.         move.w    ie_Code(a0),d0
  6254.         move.w    ie_Qualifier(a0),d1
  6255.         move.w    d1,d3
  6256.         and.w    #~(IEQUALIFIER_REPEAT|IEQUALIFIER_NUMERICPAD|IEQUALIFIER_INTERRUPT|IEQUALIFIER_RELATIVEMOUSE|IEQUALIFIER_MULTIBROADCAST),d1
  6257.         bsr    FilterDouble
  6258.         cmp.w    #IECODE_LBUTTON,d0        ; Check if mouse was pressed
  6259.         bne.s    NoSpec
  6260.         cmp.w    FullDragQual(a4),d1
  6261.         bne.s    NoSpec
  6262.         move.l    BackTask(a4),a1            ; Signal mother that button was hit
  6263.         move.l    DragSigFlag(a4),d0
  6264.         CALLSYS    Signal
  6265.         move.l    IEvent(a4),a0
  6266.         clr.b    ie_Class(a0)
  6267.         bra    NoTimerEvent
  6268.  
  6269. NoSpec        cmp.w    #IECLASS_DISKINSERTED,IEClass(a4)
  6270.         bne.s    NoDiskEvent            ; Disk inserted ?
  6271.         tst.b    WatchDisks(a4)
  6272.         beq    NoTimerEvent
  6273.         move.l    IEvent(a4),a0            ; Tell process
  6274.         move.l    #REQ_DISKCHANGE,d0
  6275.         bsr    SendEvent
  6276.         bra    NoTimerEvent
  6277.  
  6278. NoDiskEvent    cmp.w    #IECLASS_DISKREMOVED,IEClass(a4)
  6279.         bne.s    NoDiskOut
  6280.         tst.b    ScrTimeOut(a4)
  6281.         beq.s    .NoScr
  6282.         move.l    IEvent(a4),a0
  6283.         move.l    #REQ_ONSCREEN,d0
  6284.         bsr    SendEvent
  6285. .NoScr        SF    ScrTimeOut(a4)
  6286.         bra    NoTimerEvent
  6287.  
  6288. NoDiskOut    cmp.w    #IECLASS_RAWMOUSE,IEClass(a4)    ; Mouse moved ???
  6289.         bne    NoRawMouse
  6290.  
  6291.         tst.b    ShowMouse(a4)
  6292.         beq.s    .NoMouse
  6293.         bsr    SigTime
  6294.  
  6295. .NoMouse    move.l    IEvent(a4),a0            ; Get current micro seconds
  6296.         lea    ie_TimeStamp(a0),a0        ; so that checking of stopped
  6297.         move.l    TV_MICRO(a0),OldCheckMicro(a4)    ; mouse takes the same amount of time
  6298.  
  6299.         tst.b    Disabled(a4)
  6300.         bne.s    .NoMMBShift
  6301.         tst.b    MMBShift(a4)
  6302.         beq.s    .NoMMBShift
  6303.         move.l    IEvent(a4),a0
  6304.         move.w    ie_Code(a0),d0
  6305.         and.w    #~IECODE_UP_PREFIX,d0
  6306.         cmp.w    #IECODE_LBUTTON,d0
  6307.         bne.s    .NoMMBShift
  6308.         move.w    ie_Qualifier(a0),d0
  6309.         move.w    d0,d1
  6310.         and.w    #IEQUALIFIER_MIDBUTTON,d0
  6311.         beq.s    .NoMMBShift
  6312.         and.w    #~IEQUALIFIER_MIDBUTTON,d1
  6313.         or.w    #IEQUALIFIER_LSHIFT|IEQUALIFIER_RSHIFT,d1
  6314.         move.w    d1,ie_Qualifier(a0)
  6315.  
  6316. .NoMMBShift    tst.b    Disabled(a4)
  6317.         bne    .NoMouse2Menu
  6318.         tst.b    Cycled(a4)
  6319.         bne    .NoMouse2Menu
  6320.         tst.b    MenuWrap(a4)
  6321.         beq    .NoMouse2Menu
  6322.         move.l    IEvent(a4),a1            ; Check for mouse button
  6323.         move.w    ie_Code(a1),d0
  6324.         move.w    d0,d1
  6325.         and.w    #~IECODE_UP_PREFIX,d1
  6326.         cmp.w    #IECODE_RBUTTON,d1
  6327.         bne    .NoMouse2Menu
  6328.         and.w    #IECODE_UP_PREFIX,d0        ; Button released ??
  6329.         bne    .LeftMenu
  6330.         tst.b    EnteredMenu(a4)
  6331.         bne    .NoMouse2Menu
  6332.         move.l    _IntuitionBase(a4),a2        ; Check, if active window`s got a menu
  6333.         move.l    ib_ActiveWindow(a2),d0
  6334.         beq    .NoMouse2Menu
  6335.         move.l    d0,a2
  6336.         move.l    wd_MenuStrip(a2),d0
  6337.         beq    .NoMouse2Menu
  6338.         move.l    wd_Flags(a2),d0
  6339.         and.l    #WFLG_RMBTRAP,d0
  6340.         bne    .NoMouse2Menu
  6341.         ST    EnteredMenu(a4)            ; Set flag, that we`re within a menu
  6342.         link    a5,#-(ie_SIZEOF)
  6343.         lea    -(ie_SIZEOF)(a5),a0
  6344.         lea    .IePixelHin(pc),a3        ; Get address of PointerPixel
  6345.         clr.l    ie_NextEvent(a0)
  6346.         move.b    #IECLASS_NEWPOINTERPOS,ie_Class(a0)
  6347.         move.b    #IESUBCLASS_PIXEL,ie_SubClass(a0)
  6348.         clr.w    ie_Code(a0)
  6349.         clr.w    ie_Qualifier(a0)
  6350.         move.l    wd_WScreen(a2),a2
  6351.         move.w    sc_MouseX(a2),d0        ; Get mouseposition on window`s screen
  6352.         move.w    sc_MouseY(a2),d2
  6353.         move.w    d0,OldMenuX(a4)            ; Store it
  6354.         move.w    d2,OldMenuY(a4)
  6355.         move.l    a3,ie_EventAddress(a0)
  6356.         move.l    a2,iepp_Screen(a3)        ; Store new position of mouse
  6357.         move.w    d0,iepp_PositionX(a3)
  6358.         move.w    #1,iepp_PositionY(a3)
  6359.         move.l    ie_TimeStamp+TV_SECS(a1),ie_TimeStamp+TV_SECS(a0)
  6360.         move.l    ie_TimeStamp+TV_MICRO(a1),ie_TimeStamp+TV_MICRO(a0)
  6361.         LNKLIB    AddIEvents,_CxBase
  6362.         unlk    a5
  6363.         bra    NoTimerEvent
  6364. .IePixelHin    ds.b    IEPointerPixel_SIZEOF
  6365. .IePixelHer    ds.b    IEPointerPixel_SIZEOF
  6366. .LeftMenu    tst.b    EnteredMenu(a4)            ; Have been visited a menu ?
  6367.         beq    .NoMouse2Menu
  6368.         SF    EnteredMenu(a4)
  6369.         clr.b    ie_Class(a1)
  6370.         link    a5,#-ie_SIZEOF
  6371.         lea    -ie_SIZEOF(a5),a0
  6372.         clr.l    ie_NextEvent(a0)
  6373.         move.b    #IECLASS_RAWMOUSE,ie_Class(a0)
  6374.         clr.b    ie_SubClass(a0)
  6375.         move.w    #IECODE_RBUTTON|IECODE_UP_PREFIX,ie_Code(a0)
  6376.         clr.w    ie_Qualifier(a0)
  6377.         clr.l    ie_EventAddress(a0)
  6378.         move.l    ie_TimeStamp+TV_SECS(a1),ie_TimeStamp+TV_SECS(a0)
  6379.         move.l    ie_TimeStamp+TV_MICRO(a1),ie_TimeStamp+TV_MICRO(a0)
  6380.         move.l    a1,-(sp)
  6381.         LNKLIB    AddIEvents,_CxBase
  6382.         move.l    (sp)+,a1
  6383.         lea    -ie_SIZEOF(a5),a0
  6384.         lea    .IePixelHer(pc),a3
  6385.         move.b    #IECLASS_NEWPOINTERPOS,ie_Class(a0)
  6386.         move.b    #IESUBCLASS_PIXEL,ie_SubClass(a0)
  6387.         clr.w    ie_Code(a0)
  6388.         clr.w    ie_Qualifier(a0)
  6389.         move.l    _IntuitionBase(a4),a2        ; Get current screen
  6390.         move.l    ib_ActiveScreen(a2),a2
  6391.         move.l    a3,ie_EventAddress(a0)
  6392.         move.l    a2,iepp_Screen(a3)        ; Store old position
  6393.         move.w    OldMenuX(a4),iepp_PositionX(a3)
  6394.         move.w    OldMenuY(a4),iepp_PositionY(a3)
  6395.         move.l    ie_TimeStamp+TV_SECS(a1),ie_TimeStamp+TV_SECS(a0)
  6396.         move.l    ie_TimeStamp+TV_MICRO(a1),ie_TimeStamp+TV_MICRO(a0)
  6397.         DOLIB    AddIEvents
  6398.         unlk    a5
  6399.         bra    NoTimerEvent
  6400.  
  6401. .NoMouse2Menu    tst.b    Disabled(a4)            ; Menu to mouse ???
  6402.         bne    .NoWrap
  6403.         tst.b    EnteredMenu(a4)
  6404.         beq    .NoWrap
  6405. .CheckWrap    move.l    _IntuitionBase(a4),a2
  6406.         move.l    ib_ActiveWindow(a2),a2
  6407.         move.l    wd_MenuStrip(a2),a0        ; Now calc width of menu strip
  6408. .LoopStrip    tst.l    mu_NextMenu(a0)
  6409.         beq.s    .GotLast
  6410.         move.l    mu_NextMenu(a0),a0
  6411.         bra.s    .LoopStrip
  6412. .GotLast    move.w    mu_LeftEdge(a0),d7
  6413.         move.l    mu_FirstItem(a0),a0
  6414.         moveq    #0,d6
  6415. .GetLargest    move.l    a0,d0
  6416.         beq.s    .GotLargest
  6417.         cmp.w    mi_Width(a0),d6
  6418.         bge.s    .NotLarger
  6419.         move.w    mi_Width(a0),d6
  6420. .NotLarger    move.l    mi_NextItem(a0),a0
  6421.         bra.s    .GetLargest
  6422. .GotLargest    add.w    d6,d7                ; d7 =  width of menustrip
  6423.         subq.w    #2,d7
  6424.         move.l    wd_WScreen(a2),a2        ; Get address of screen
  6425.         move.w    sc_Width(a2),d0
  6426.         subq.w    #1,d0
  6427.         cmp.w    sc_MouseX(a2),d0
  6428.         ble.s    .DoRightWrap
  6429.         cmp.w    sc_MouseX(a2),d7        ; Mouse position "over" menu ?
  6430.         bgt.s    .NoRightWrap
  6431. .DoRightWrap    moveq    #2,d7                ; Yep -> store new pos
  6432.         bra.s    .DoWrap
  6433. .NoRightWrap    tst.w    sc_MouseX(a2)            ; Mouse under left bound ?
  6434.         bgt.s    .NoWrap
  6435.         subq.w    #2,d7                ; Yep Store new pos
  6436. .DoWrap        link    a5,#-ie_SIZEOF
  6437.         lea    -(ie_SIZEOF)(a5),a0
  6438.         lea    .IePixelZip(pc),a3
  6439.         clr.l    ie_NextEvent(a0)
  6440.         move.b    #IECLASS_NEWPOINTERPOS,ie_Class(a0)
  6441.         move.b    #IESUBCLASS_PIXEL,ie_SubClass(a0)
  6442.         clr.w    ie_Code(a0)
  6443.         clr.w    ie_Qualifier(a0)
  6444.         move.l    a3,ie_EventAddress(a0)
  6445.         move.l    a2,iepp_Screen(a3)        ; Store old position
  6446.         move.w    d7,iepp_PositionX(a3)
  6447.         move.w    #1,iepp_PositionY(a3)
  6448.         move.w    ie_TimeStamp+TV_SECS(a1),ie_TimeStamp+TV_SECS(a0)
  6449.         move.w    ie_TimeStamp+TV_MICRO(a1),ie_TimeStamp+TV_MICRO(a0)
  6450.         LNKLIB    AddIEvents,_CxBase        ; And move
  6451.         unlk    a5
  6452.         bra    NoTimerEvent
  6453. .IePixelZip    ds.b    IEPointerPixel_SIZEOF
  6454.  
  6455. .NoWrap        tst.b    Disabled(a4)
  6456.         bne    NoTimerEvent
  6457.         tst.b    DoActivate(a4)            ; Activation of Windows ?
  6458.         beq    .End1
  6459.         tst.b    SunMouse(a4)            ; MousMode active ?
  6460.         beq    .End1
  6461.         move.l    IEvent(a4),a0            ; Get current event
  6462.         move.w    ie_Code(a0),d0
  6463.         cmp.w    #IECODE_NOBUTTON,d0        ; Any button pressed ?
  6464.         bne    .End1                ; Yep -> no activation
  6465.         move.w    ie_Qualifier(a0),d0        ; Any button pressed ?
  6466.         and.w    #(IEQUALIFIER_LEFTBUTTON|IEQUALIFIER_RBUTTON|IEQUALIFIER_MIDBUTTON),d0
  6467.         bne    .End1                ; No activation
  6468.         ST    StartSunMouse(a4)
  6469.         move.l    _IntuitionBase(a4),a6
  6470.         move.w    ib_MouseX(a6),d0        ; Get current mouse-position
  6471.         move.w    ib_MouseY(a6),d1
  6472.         move.w    OldX(a4),d2
  6473.         move.w    OldY(a4),d3    
  6474.         tst.w    d2
  6475.         blt.s    .NoEnd1
  6476.         sub.w    d0,d2
  6477.         bge.s    .XPos
  6478.         neg.w    d2
  6479. .XPos        cmp.w    #15,d2
  6480.         bgt.s    .End1
  6481.         sub.w    d1,d3
  6482.         bge.s    .YPos
  6483.         neg.w    d3
  6484. .YPos        cmp.w    #15,d3
  6485.         bgt.s    .End1
  6486. .NoEnd1        move.w    d0,OldX(a4)            ; Store new one
  6487.         move.w    d1,OldY(a4)
  6488.         RELLIB    FindWindow,_KCXBase
  6489.         tst.l    d0
  6490.         beq.s    .End1
  6491.         move.l    d0,a0
  6492.         move.l    lr_Window(a0),d0
  6493.         beq.s    .End1
  6494.         move.l    _IntuitionBase(a4),a0
  6495.         cmp.l    ib_ActiveWindow(a0),d0
  6496.         beq.s    .End1
  6497.         move.l    ib_ActiveWindow(a0),a0
  6498.         move.l    wd_Flags(a0),d0
  6499.         and.l    #WFLG_MENUSTATE,d0
  6500.         bne.s    .End1
  6501.         move.l    _IntuitionBase(a4),a0
  6502.         move.l    ib_ActiveWindow(a0),a0
  6503.         bsr    CheckWinGads
  6504.         move.l    a0,d0
  6505.         beq.s    .End1
  6506.         move.l    IEvent(a4),a0
  6507.         move.l    #REQ_ACTIVATE,d0
  6508.         bsr    SendEvent
  6509.  
  6510. .End1        move.l    IEvent(a4),a0
  6511.         move.l    #REQ_RAWMOUSE,d0
  6512.         bsr    SendEvent
  6513.         bra    NoTimerEvent
  6514.  
  6515. NoRawMouse    cmp.w    #IECLASS_RAWKEY,IEClass(a4)    ; Key pressed ???
  6516.         bne    NoRawKey
  6517.  
  6518.         tst.b    Disabled(a4)            ; Check for AltMode
  6519.         bne    .NoAltCodes
  6520.         tst.b    AltModeOn(a4)
  6521.         beq    .NoAltCodes
  6522.         move.l    IEvent(a4),a1            ; Get current key
  6523.         moveq    #0,d0
  6524.         moveq    #0,d1
  6525.         move.w    ie_Code(a1),d0
  6526.         move.w    ie_Qualifier(a1),d1
  6527.         move.w    d1,d2
  6528.         move.w    d0,d3
  6529.         and.w    #~(IEQUALIFIER_REPEAT|IEQUALIFIER_NUMERICPAD|IEQUALIFIER_INTERRUPT|IEQUALIFIER_RELATIVEMOUSE|IEQUALIFIER_MULTIBROADCAST),d1
  6530.  
  6531.         tst.w    AltQual(a4)            ; Which qualifier to use ?
  6532.         beq.s    .CheckForAlt
  6533.         move.w    #$63,d4                ; Get CONTROL CODE
  6534.         move.w    #IEQUALIFIER_CONTROL,d5        ; Get CONTROL QUALIFIER
  6535.         bra.s    .Check
  6536. .CheckForAlt    move.w    #$64,d4                ; Get ALT CODE
  6537.         move.w    #IEQUALIFIER_LALT,d5        ; Get ALT QUALIFIER
  6538.  
  6539. .Check        and.w    #~IECODE_UP_PREFIX,d3
  6540.         and.w    #IECODE_UP_PREFIX,d0
  6541.         beq.s    .DownKey
  6542.         cmp.w    d4,d3                ; Qualifier hit ?
  6543.         bne    .NoAltCodes
  6544.         tst.w    NumAltCodes(a4)
  6545.         bne    .LeftAltMode
  6546.         bra    .NoAltCodes
  6547.  
  6548. .DownKey    cmp.w    d0,d4                ; CODE Hit ?
  6549.         beq.s    .NoCode                ; Yep -> Start Sequence
  6550.  
  6551. .GotAltQual    cmp.w    d5,d1                ; Check for Qualifier
  6552.         bne.s    .NoCode
  6553.         tst.b    EnteredAltMode(a4)        ; Alread in ALTMode ?
  6554.         bne.s    .CheckCode
  6555. .NoCode        ST    EnteredAltMode(a4)        ; Set flag, that we`re within AltMode
  6556.         clr.w    AltCode(a4)            ; Reset counters
  6557.         clr.w    NumAltCodes(a4)
  6558.         bra    .NoAltCodes            ; Skip this now
  6559.  
  6560. .CheckCode    and.w    #IEQUALIFIER_NUMERICPAD,d2    ; Key from Numeric Pad ?
  6561.         beq    .NoCode
  6562.         link    a5,#-20                ; Get code
  6563.         move.l    IEvent(a4),a0            ; Convert RawKey to ASCII
  6564.         move.w    ie_Qualifier(a0),d6
  6565.         clr.w    ie_Qualifier(a0)
  6566.         lea    -20(a5),a1
  6567.         clr.b    (a1)
  6568.         move.l    #19,d1
  6569.         sub.l    a2,a2
  6570.         RELLIB    MapRawKey,_KeyMapBase
  6571.         moveq    #0,d7                ; Get code
  6572.         move.b    -20(a5),d7
  6573.         unlk    a5
  6574.         move.l    IEvent(a4),a0
  6575.         move.w    d6,ie_Qualifier(a0)
  6576.         cmp.b    #'0',d7                ; Is it a digit ???
  6577.         blt    .NoCode
  6578.         cmp.b    #'9',d7
  6579.         bgt    .NoCode
  6580.         sub.b    #'0',d7                ; Calc value of digit
  6581.         move.w    AltCode(a4),d0
  6582.         add.w    d7,d0
  6583.         mulu    #10,d0                ; shift within decimals
  6584.         move.w    d0,AltCode(a4)
  6585.         move.l    IEvent(a4),a0            ; Clear this event
  6586.         clr.b    ie_Class(a0)
  6587.         addq.w    #1,NumAltCodes(a4)        ; One digit done
  6588.         cmp.w    #3,NumAltCodes(a4)        ; All three entered ??
  6589.         bne    .NoAltCodes            ; Nope -> go on
  6590. .LeftAltMode    moveq    #0,d0                ; Get current code
  6591.         move.w    AltCode(a4),d0
  6592.         divu    #10,d0
  6593.         lsl.w    #8,d0
  6594.         and.w    #$ff00,d0            ; D0 = Value with trailing Zero
  6595.         move.w    d0,AltCode(a4)
  6596.         link    a5,#-12                ; Reconvert code to RawKey
  6597.         lea    AltCode(a4),a0
  6598.         moveq    #1,d0
  6599.         lea    -12(a5),a1
  6600.         moveq    #6,d1
  6601.         sub.l    a2,a2
  6602.         RELLIB    MapANSI,_KeyMapBase
  6603.         tst.l    d0
  6604.         bge.s    .GotCode
  6605.         unlk    a5
  6606.         bra    .NoCode
  6607. .GotCode    move.l    IEvent(a4),a0            ; Generate Event out of old one
  6608.         lea    -12(a5),a1            ; with all previous keys needed
  6609.         move.b    #IECLASS_RAWKEY,ie_Class(a0)
  6610.         clr.b    ie_SubClass(a0)
  6611.         clr.b    ie_Prev2DownCode(a0)
  6612.         clr.b    ie_Prev2DownQual(a0)
  6613.         clr.b    ie_Prev1DownCode(a0)
  6614.         clr.b    ie_Prev1DownQual(a0)
  6615.         cmp.w    #3,d0                ; Check for "length" of new Event
  6616.         bne.s    .No3
  6617.         move.b    (a1)+,ie_Prev2DownCode(a0)    ; Create new event
  6618.         move.b    (a1)+,ie_Prev2DownQual(a0)
  6619.         bra.s    .Do2
  6620. .No3        cmp.w    #2,d0
  6621.         bne.s    .No2
  6622. .Do2        move.b    (a1)+,ie_Prev1DownCode(a0)
  6623.         move.b    (a1)+,ie_Prev1DownQual(a0)
  6624.         bra.s    .Do1
  6625. .No2        cmp.w    #1,d0
  6626.         bne.s    .No1
  6627. .Do1        moveq    #0,d1
  6628.         moveq    #0,d2
  6629.         move.b    (a1)+,d1
  6630.         move.b    (a1),d2
  6631.         move.w    d1,ie_Code(a0)
  6632.         move.w    d2,ie_Qualifier(a0)
  6633. .No1        unlk    a5
  6634.         bra    .NoCode
  6635.  
  6636. .NoAltCodes    move.l    IEvent(a4),a1            ; If key released -> break
  6637.         move.w    ie_Code(a1),d0
  6638.         and.w    #IECODE_UP_PREFIX,d0
  6639.         bne    NoTimerEvent
  6640.  
  6641.         tst.b    ScrTimeOut(a4)
  6642.         beq.s    .NotDimmed
  6643.         tst.l    DimmBase(a4)
  6644.         bne.s    .NotDimmed
  6645.         move.l    IEvent(a4),a0            ; Only kill char if not dimmed
  6646.         clr.b    ie_Class(a0)
  6647.  
  6648. .NotDimmed    tst.b    Disabled(a4)
  6649.         bne.s    .NoKey
  6650.  
  6651.         move.l    IEvent(a4),a1            ; Check for "patched" amiga m/n keys
  6652.         move.w    ie_Qualifier(a1),d0
  6653.         move.w    d0,d1
  6654.         and.w    #IEQUALIFIER_REPEAT,d1        ; only act on non-repeated keys
  6655.         bne.s    .NoLAmiga
  6656.         and.w    #IEQUALIFIER_LCOMMAND,d0
  6657.         beq.s    .NoLAmiga
  6658.         move.l    _IntuitionBase(a4),a0
  6659.         cmp.w    #$37,ie_Code(a1)
  6660.         bne.s    .NoM
  6661.         clr.b    ie_Class(a1)
  6662.         move.l    #REQ_SCRBACK,d0            ; Send a screen to back
  6663.         bsr    SendEvent
  6664.         bra    NoTimerEvent
  6665. .NoM        cmp.w    #$36,ie_Code(a1)
  6666.         bne.s    .NoLAmiga
  6667.         clr.b    ie_Class(a1)            ; Bring WB to front
  6668.         move.l    #REQ_WBFRONT,d0
  6669.         bsr    SendEvent
  6670.         bra    NoTimerEvent
  6671.  
  6672. .NoLAmiga    move.l    IEvent(a4),a0
  6673.         move.l    #REQ_RAWKEY,d0
  6674.         bsr    SendEvent
  6675.  
  6676. .NoKey        tst.b    Disabled(a4)
  6677.         bne.s    .NoClickYet
  6678.         tst.b    KeyClick(a4)            ; Enabled Key-Click ?
  6679.         beq.s    .NoClickYet
  6680.         link    a5,#-128
  6681.         move.l    IEvent(a4),a0            ; Convert RAW-Key
  6682.         lea    -128(a5),a1
  6683.         clr.b    (a1)                ; Clear previous keys
  6684.         moveq    #127,d1
  6685.         sub.l    a2,a2
  6686.         RELLIB    MapRawKey,_KeyMapBase        ; Convert raw key
  6687.         lea    -128(a5),a1
  6688.         move.b    (a1),d0
  6689.         unlk    a5
  6690.         tst.b    d0                ; No keys ?
  6691.         beq.s    .NoClickYet
  6692.         cmp.b    #$9b,d0                ; Initial ANSI-Code
  6693.         beq.s    .NoClickYet            ; No click
  6694.         cmp.b    #$09,d0                ; TAB-Key pressed ?
  6695.         beq.s    .NoClickYet
  6696.  
  6697. .NoClickYet    tst.b    Disabled(a4)            ; Allow Shortcuts from within String gadgets ???
  6698.         bne    .NoRAmiga
  6699.         tst.b    StringMenu(a4)
  6700.         beq    .NoRAmiga
  6701.         move.l    IEvent(a4),a0
  6702.         move.w    ie_Code(a0),d0
  6703.         and.w    #IECODE_UP_PREFIX,d0
  6704.         bne    .NoRAmiga
  6705.         move.w    ie_Qualifier(a0),d0
  6706.         and.w    #IEQUALIFIER_REPEAT,d0
  6707.         bne    .NoRAmiga
  6708.         move.w    ie_Qualifier(a0),d0
  6709.         and.w    #IEQUALIFIER_RCOMMAND,d0
  6710.         beq    .NoRAmiga
  6711.         move.l    _IntuitionBase(a4),a3
  6712.         move.l    ib_ActiveWindow(a3),a3
  6713.         tst.l    wd_MenuStrip(a3)
  6714.         beq    .NoRAmiga
  6715.         link    a5,#-2                ; Get code pressed and convert to vanillakay
  6716.         move.l    IEvent(a4),a0
  6717.         move.w    ie_Qualifier(a0),d6
  6718.         and.w    #IEQUALIFIER_LSHIFT|IEQUALIFIER_RSHIFT|IEQUALIFIER_LALT|IEQUALIFIER_RALT,ie_Qualifier(a0)
  6719.         lea    -2(a5),a1
  6720.         clr.b    (a1)
  6721.         moveq    #1,d1
  6722.         sub.l    a2,a2
  6723.         RELLIB    MapRawKey,_KeyMapBase
  6724.         moveq    #0,d7                ; Get code
  6725.         move.b    -2(a5),d7
  6726.         unlk    a5
  6727.         move.l    IEvent(a4),a0
  6728.         move.w    d6,ie_Qualifier(a0)
  6729.         cmp.b    #'x',d7
  6730.         beq    .NoRAmiga
  6731.         cmp.b    #'q',d7
  6732.         beq    .NoRAmiga
  6733.         move.l    _IntuitionBase(a4),a0        ; Check for active str-gadgets within window
  6734.         move.l    ib_ActiveWindow(a0),a0
  6735.         move.l    a0,-(sp)
  6736.         bsr    CheckWinGads
  6737.         move.l    (sp)+,a1
  6738.         move.l    a0,d0
  6739.         bne    .NoRAmiga            ; No active String Menu -> Go On
  6740.         move.l    a1,a3
  6741.         moveq    #1,d6                ; Set number for checks
  6742. .CheckForUpper    move.l    wd_MenuStrip(a3),a0
  6743.         tst.b    d6
  6744.         bne.s    .NoUpperInput
  6745.         move.l    d7,d0
  6746.         bsr    GetUpperCase
  6747.         move.l    d0,d7
  6748. .NoUpperInput    moveq    #0,d1                ; Menu number
  6749. .LoopMenus    move.l    a0,d0                ; Loop for menus
  6750.         beq.s    .CheckLoop
  6751.         move.l    mu_FirstItem(a0),a1        ; Loop for items
  6752.         moveq    #0,d2                ; Item number
  6753. .LoopItems    move.l    a1,d0
  6754.         beq.s    .NoItems
  6755.         move.l    mi_SubItem(a1),a2        ; Loop for subitems
  6756.         moveq    #0,d3                ; SubItem number
  6757. .LoopSubs    move.l    a2,d0
  6758.         beq.s    .NoSubs
  6759.         move.w    mi_Flags(a2),d0
  6760.         and.w    #COMMSEQ,d0            ; Check for Command-Key within SubItem
  6761.         beq.s    .NoSubCommand
  6762.         moveq    #0,d0
  6763.         move.b    mi_Command(a2),d0
  6764.         tst.b    d6
  6765.         bne.s    .NoUpperItem
  6766.         bsr    GetUpperCase
  6767. .NoUpperItem    cmp.b    d0,d7
  6768.         bne.s    .NoSubCommand
  6769.         move.w    #-1,mi_NextSelect(a2)
  6770.         bra.s    .GotMenu
  6771. .NoSubCommand    move.l    mi_NextItem(a2),a2        ; Get Pointer to next subitem
  6772.         addq.w    #1,d3
  6773.         bra.s    .LoopSubs
  6774. .NoSubs        move.w    mi_Flags(a1),d0
  6775.         and.w    #COMMSEQ,d0            ; Check for Command-Key within MenuItem
  6776.         beq.s    .NoItemCommand
  6777.         moveq    #0,d0
  6778.         move.b    mi_Command(a1),d0
  6779.         tst.b    d6
  6780.         bne.s    .NoUpperSub
  6781.         bsr    GetUpperCase
  6782. .NoUpperSub    cmp.b    d0,d7
  6783.         bne.s    .NoItemCommand
  6784.         move.w    #-1,mi_NextSelect(a1)
  6785.         bra.s    .GotMenu
  6786. .NoItemCommand    move.l    mi_NextItem(a1),a1        ; Get Pointer to next item
  6787.         addq.w    #1,d2
  6788.         bra    .LoopItems
  6789. .NoItems    move.l    mu_NextMenu(a0),a0        ; Get Pointer to next menu
  6790.         addq.w    #1,d1
  6791.         bra    .LoopMenus
  6792. .CheckLoop    dbf    d6,.CheckForUpper
  6793.         bra.s    .NoRAmiga
  6794. .GotMenu    and.w    #$01f,d1            ; Calc correct menu number
  6795.         and.w    #$02f,d2
  6796.         and.w    #$01f,d3
  6797.         lsl.w    #5,d2
  6798.         lsl.w    #8,d3
  6799.         lsl.w    #3,d3
  6800.         or.w    d2,d1
  6801.         or.w    d3,d1
  6802.         move.l    IEvent(a4),a0            ; Convert RawKey-Event to
  6803.         move.b    #IECLASS_MENULIST,ie_Class(a0)    ; Set item type to be menupick
  6804.         clr.b    ie_SubClass(a0)            ; Clear subclass
  6805.         move.w    d1,ie_Code(a0)            ; Set menunumber
  6806.         clr.w    ie_Qualifier(a0)        ; No qualifier
  6807.         move.l    a3,ie_EventAddress(a0)        ; Set destination window
  6808.  
  6809. .NoRAmiga    tst.b    Disabled(a4)
  6810.         bne    .NoFKeys
  6811.         tst.b    FKeysOn(a4)            ; FKeys enabled ?
  6812.         beq    .NoFKeys
  6813.         move.l    IEvent(a4),a1
  6814.         move.w    ie_Code(a1),d0
  6815.         cmp.w    #$50,d0
  6816.         blt    .NoFKeys
  6817.         cmp.w    #$59,d0
  6818.         bgt    .NoFKeys
  6819.         move.w    ie_Qualifier(a1),d1
  6820.         and.w    #~(IEQUALIFIER_REPEAT|IEQUALIFIER_NUMERICPAD|IEQUALIFIER_INTERRUPT|IEQUALIFIER_RELATIVEMOUSE|IEQUALIFIER_MULTIBROADCAST),d1
  6821.         bsr    FilterDouble
  6822.         moveq    #0,d7
  6823.         moveq    #3,d6
  6824.         lea    FKeyQualFlags,a0
  6825. .CheckQual    cmp.w    (a0)+,d1
  6826.         beq.s    .GotQual
  6827.         cmp.w    (a0)+,d1
  6828.         beq.s    .GotQual
  6829.         add.l    #(MAXFKEYWIDTH+2)*10,d7
  6830.         dbf    d6,.CheckQual
  6831.         bra    .NoFKeys
  6832. .GotQual    lea    FKeys(a4),a0
  6833.         lea    0(a0,d7),a0
  6834.         sub.w    #$50,d0
  6835.         mulu    #(MAXFKEYWIDTH+2),d0
  6836.         lea    0(a0,d0.w),a0
  6837.         lea    FKeyCmds,a2            ; Check for any commands entered
  6838.         lea    FKeyRouts,a3
  6839.         move.w    #FKEYCMDNUM-1,d6
  6840. .CheckCmds    move.l    (a2)+,a1
  6841.         moveq    #-1,d7
  6842.         bsr    StrCmp2
  6843.         tst.l    d0
  6844.         bne.s    .NoCmd
  6845.         move.l    (a3),a3
  6846.         jsr    (a3)
  6847.         bra    .NoFKeys
  6848. .NoCmd        addq.l    #4,a3
  6849.         dbf    d6,.CheckCmds
  6850.         clr.l    -(a7)
  6851.         move.l    a0,-(a7)
  6852.         jsr    _InvertString            ; Invert String "inverts" the string
  6853.         addq.l    #8,sp                ; but we can`t simply reverse the string
  6854.         tst.l    d0                ; otherwise all special codes will get lost
  6855.         beq    .NoFKeys            ; so we flip the list of events now
  6856.         move.l    d0,a0
  6857.         move.l    d0,a5                ; Store pointer to events
  6858.         moveq    #4,d0                ; Calc number of events
  6859. .Loop        tst.l    ie_NextEvent(a0)
  6860.         beq.s    .Done
  6861.         addq.l    #4,d0
  6862.         move.l    ie_NextEvent(a0),a0
  6863.         bra.s    .Loop
  6864. .Done        move.l    d0,d7
  6865.         lsr.l    #2,d7                ; Alloc table for pointers
  6866.         move.l    #MEMF_CLEAR,d1
  6867.         CALLSYS    AllocVec
  6868.         tst.l    d0
  6869.         beq.s    .NoTable
  6870.         move.l    a5,a0                ; Copy adresses of events
  6871.         move.l    d0,a3
  6872.         move.l    d0,a1
  6873.         move.l    d7,d0
  6874.         subq.w    #1,d0
  6875. .CopyPtrs    move.l    a0,(a1)+            ; Store all addresses of events
  6876.         move.l    ie_NextEvent(a0),a0        ; within table
  6877.         dbf    d0,.CopyPtrs
  6878.         move.l    a3,a0                ; Remake pointers
  6879.         subq.w    #1,d7                ; sub one
  6880.         move.l    d7,d0
  6881.         lsl.l    #2,d0                ; Calc offset
  6882.         lea    0(a0,d0),a0            ; a0 points to end of list
  6883.         move.l    (a0),a5                ; Get address of "last" event
  6884.         subq.w    #1,d7                ; sub one for loop
  6885.         blt.s    .OnlyOne            ; Ok -> There only way one
  6886. .Remake        move.l    (a0),a1                ; Get address of event
  6887.         move.l    -4(a0),ie_NextEvent(a1)        ; Create link to previous one
  6888.         subq.l    #4,a0                ; Next event
  6889.         dbf    d7,.Remake
  6890. .OnlyOne    move.l    (a0),a0                ; Get last event
  6891.         clr.l    ie_NextEvent(a0)        ; Clear old link
  6892.         move.l    a5,a0                ; Add events
  6893.         LNKLIB    AddIEvents,_CxBase
  6894.         move.l    IEvent(a4),a0
  6895.         clr.b    ie_Class(a0)
  6896. .NoEvents    move.l    a3,a1                ; Free table
  6897.         CALLSYS    FreeVec
  6898. .NoTable    move.l    a5,-(sp)            ; Free events
  6899.         jsr    _FreeIEvents
  6900.         addq.l    #4,sp
  6901.  
  6902. .NoFKeys    tst.b    Disabled(a4)
  6903.         bne.s    .NoEscape
  6904.         tst.b    ESCClose(a4)            ; Allow closing of windows
  6905.         beq.s    .NoEscape            ; via ESC-Key ???
  6906.         move.l    IEvent(a4),a1
  6907.         cmp.w    #RESCKEY,ie_Code(a1)
  6908.         bne.s    .NoEscape
  6909.         move.w    ie_Qualifier(a1),d1
  6910.         and.w    #~(IEQUALIFIER_REPEAT|IEQUALIFIER_NUMERICPAD|IEQUALIFIER_INTERRUPT|IEQUALIFIER_RELATIVEMOUSE|IEQUALIFIER_MULTIBROADCAST),d1
  6911.         move.w    #RESCKEY,d0
  6912.         bsr    FilterDouble
  6913.         cmp.w    ESCQual(a4),d1
  6914.         bne.s    .NoEscape
  6915.         move.l    _IntuitionBase(a4),a0
  6916.         move.l    ib_ActiveWindow(a0),a3
  6917.         move.l    a3,d0
  6918.         beq.s    .NoEscape            ; Yep -> no close
  6919.         move.l    wd_Flags(a3),d0            ; Window has a closegadget ?
  6920.         and.l    #WFLG_CLOSEGADGET,d0
  6921.         beq.s    .NoEscape            ; Nope -> go on
  6922.         tst.l    wd_FirstRequest(a3)        ; Requester visible ???
  6923.         bne.s    .NoEscape
  6924. .IsAct        link    a5,#-ie_SIZEOF
  6925.         lea    -ie_SIZEOF(a5),a0        ; fill in Event structure
  6926.         clr.l    ie_NextEvent(a0)
  6927.         move.b    #IECLASS_CLOSEWINDOW,ie_Class(a0)
  6928.         clr.b    ie_SubClass(a0)
  6929.         clr.w    ie_Code(a0)
  6930.         clr.w    ie_Qualifier(a0)
  6931.         move.l    a3,ie_EventAddress(a0)
  6932.         LNKLIB    AddIEvents,_CxBase        ; Add event
  6933.         unlk    a5
  6934.         bra    NoTimerEvent
  6935.  
  6936. .NoEscape    tst.b    Disabled(a4)
  6937.         bne.s    .CheckMouseOff
  6938.         tst.b    DoActivate(a4)            ; Window activation set ?
  6939.         beq.s    .CheckMouseOff
  6940.         tst.b    SunMouse(a4)
  6941.         bne.s    .CheckMouseOff
  6942.         RELLIB    FindWindow,_KCXBase        ; Check window underneith mouse
  6943.         tst.l    d0
  6944.         beq.s    .CheckMouseOff
  6945.         move.l    d0,a0
  6946.         move.l    lr_Window(a0),d0
  6947.         beq.s    .CheckMouseOff
  6948.         move.l    _IntuitionBase(a4),a0        ; Still the same ?
  6949.         cmp.l    ib_ActiveWindow(a0),d0
  6950.         beq.s    .CheckMouseOff
  6951.         move.l    ib_ActiveWindow(a0),a0
  6952.         move.l    wd_Flags(a0),d0
  6953.         and.l    #WFLG_MENUSTATE,d0
  6954.         bne.s    .CheckMouseOff
  6955.         move.l    _IntuitionBase(a4),a0
  6956.         move.l    ib_ActiveWindow(a0),a0        ; Check for active gadgets
  6957.         bsr    CheckWinGads            ; on current window
  6958.         move.l    a0,d0
  6959.         beq.s    .CheckMouseOff
  6960.         move.l    IEvent(a4),a0
  6961.         move.l    #REQ_ACTIVATE,d0
  6962.         bsr    SendEvent
  6963.         move.l    IEvent(a4),a0
  6964.         clr.b    ie_Class(a0)
  6965.  
  6966. .CheckMouseOff    tst.b    Disabled(a4)
  6967.         bne    .NoUmlaut
  6968.         tst.b    MapUmlaut(a4)            ; Map "Umlauts" ?
  6969.         beq    .NoUmlaut
  6970.         move.l    IEvent(a4),a1            ; Check for "Umlauts"
  6971.         move.w    ie_Qualifier(a1),d1        ; Only accept plain and shifted keys
  6972.         and.w    #~(IEQUALIFIER_REPEAT|IEQUALIFIER_NUMERICPAD|IEQUALIFIER_INTERRUPT|IEQUALIFIER_RELATIVEMOUSE|IEQUALIFIER_MULTIBROADCAST),d1
  6973.         move.w    d1,d2
  6974.         and.w    #(IEQUALIFIER_LALT|IEQUALIFIER_RALT|IEQUALIFIER_LCOMMAND|IEQUALIFIER_RCOMMAND),d2
  6975.         bne    .NoUmlaut
  6976.         movem.l    d1/a1,-(sp)
  6977.         link    a5,#-20
  6978.         move.l    a1,a0
  6979.         lea    -20(a5),a1
  6980.         clr.b    (a1)
  6981.         move.l    #19,d1
  6982.         sub.l    a2,a2
  6983.         RELLIB    MapRawKey,_KeyMapBase
  6984.         moveq    #0,d0
  6985.         move.b    -20(a5),d0
  6986.         unlk    a5
  6987.         movem.l    (sp)+,d1/a1
  6988. .UmlautOk    lea    UmlautTab(pc),a3        ; Get UmlautTab
  6989.         moveq    #7,d7
  6990. .GetUmlaut    cmp.w    (a3),d0                ; Got "Umlaut" ?
  6991.         beq.s    .GotUmlaut            ; Yep -> go on
  6992.         addq.l    #6,a3
  6993.         dbf    d7,.GetUmlaut
  6994.         bra.s    .NoUmlaut            ; No "Umlaut"
  6995. .GotUmlaut    cmp.b    #'ß',d0
  6996.         bne.s    .NoSS
  6997.         move.w    d1,d0
  6998.         and.w    #(IEQUALIFIER_LSHIFT|IEQUALIFIER_RSHIFT),d0
  6999.         bne.s    .NoUmlaut
  7000.         bra.s    .NoShift
  7001. .NoSS        tst.w    (a3)                ; Skip shifted ß
  7002.         beq.s    .NoUmlaut
  7003.  
  7004. .NoShift    link    a5,#-ie_SIZEOF            ; Get space for one IEs
  7005.         move.b    ie_SubClass(a1),d0        ; Get subclass
  7006.         move.l    ie_EventAddress(a1),d2        ; Address
  7007.  
  7008.         clr.b    ie_Class(a1)            ; Clear current event
  7009.  
  7010.         lea    -ie_SIZEOF(a5),a0        ; Create new event -> Clear link to next
  7011.         clr.l    ie_NextEvent(a0)
  7012.         move.b    #IECLASS_RAWKEY,ie_Class(a0)
  7013.         move.b    d0,ie_SubClass(a0)
  7014.         move.w    2(a3),ie_Code(a0)        ; Get first char for "Umlaut"
  7015.         move.w    d1,ie_Qualifier(a0)
  7016.         move.l    d2,ie_EventAddress(a0)
  7017.         LNKLIB    AddIEvents,_CxBase        ; Add events
  7018.         lea    -ie_SIZEOF(a5),a0
  7019.         move.w    4(a3),ie_Code(a0)        ; Get second char for "Umlaut"
  7020.         and.w    #~(IEQUALIFIER_LSHIFT|IEQUALIFIER_RSHIFT),ie_Qualifier(a0)
  7021.         DOLIB    AddIEvents
  7022.         unlk    a5
  7023.  
  7024. .NoUmlaut    bra    NoTimerEvent
  7025.  
  7026.  
  7027. NoRawKey    cmp.w    #IECLASS_TIMER,IEClass(a4)    ; Timer event ?
  7028.         bne    NoTimerEvent
  7029.  
  7030.         tst.b    MouseIsOff(a4)
  7031.         beq.s    .NoMouseOff
  7032.         move.w    MouseOffCount(a4),d0
  7033.         addq.w    #1,d0
  7034.         move.w    d0,MouseOffCount(a4)
  7035.         cmp.w    #10,d0
  7036.         bne.s    .NoMouseOff
  7037.         clr.b    MouseIsOff(a4)
  7038.         bsr    OffMouse
  7039.         clr.w    MouseOffCount(a4)
  7040.  
  7041. .NoMouseOff    tst.l    BlankScrHandle(a4)        ; Do we have a "blank screen" ?
  7042.         bne.s    .CheckScreen
  7043.         tst.l    DimmBase(a4)
  7044.         beq.s    .NoOnScreen
  7045.  
  7046. .CheckScreen    move.l    _IntuitionBase(a4),a0
  7047.         move.l    ib_FirstScreen(a0),a0
  7048.  
  7049.         tst.b    ScreenDimm(a4)
  7050.         bne.s    .NoOnScreen
  7051.         cmp.l    BlankScrHandle(a4),a0        ; If not close it
  7052.         beq.s    .NoOnScreen
  7053.         move.l    IEvent(a4),a0
  7054.         move.l    #REQ_ONSCREEN,d0
  7055.         bsr    SendEvent
  7056.  
  7057. .NoOnScreen    tst.b    Disabled(a4)
  7058.         bne    .NoCheck
  7059.         move.l    IEvent(a4),a0            ; A little delay for check
  7060.         lea    ie_TimeStamp(a0),a0        ; Only check every half a second
  7061.         move.l    TV_MICRO(a0),d0            ; If mouse was moved
  7062.         move.l    d0,d1                ; so that SUN-Mouse may
  7063.         move.l    OldCheckMicro(a4),d2        ; activate windows if the
  7064.         sub.l    d2,d0                ; mouse has come to a complete
  7065.         bge.s    .IsPos                ; stop
  7066.         neg.l    d0
  7067. .IsPos        cmp.l    #100000,d0
  7068.         blt    .NoCheck
  7069.         move.l    d1,OldCheckMicro(a4)
  7070.         move.w    #-1,OldX(a4)
  7071.         tst.b    DoActivate(a4)            ; WindowActivation active ?
  7072.         beq    .NoCheck
  7073.         tst.b    SunMouse(a4)            ; Mouse mode active ?
  7074.         beq    .NoCheck
  7075.         move.l    _IntuitionBase(a4),a6
  7076.         move.w    ib_MouseX(a6),d5        ; Get current mouse position
  7077.         move.w    ib_MouseY(a6),d6
  7078.         move.w    CheckX(a4),d2            ; Get old position
  7079.         move.w    CheckY(a4),d3
  7080.         move.w    d5,CheckX(a4)            ; Store new one
  7081.         move.w    d6,CheckY(a4)
  7082.         cmp.w    d5,d2                ; Mouse moved since last change ?
  7083.         bne.s    .NoCheck1
  7084.         cmp.w    d6,d3
  7085.         bne.s    .NoCheck1
  7086.         tst.b    Moved(a4)            ; Already activated on that position ?
  7087.         bne.s    .NoCheck
  7088.         RELLIB    FindWindow,_KCXBase
  7089.         tst.l    d0
  7090.         beq.s    .NoCheck
  7091.         move.l    d0,a0
  7092.         move.l    lr_Window(a0),d0
  7093.         beq.s    .NoCheck
  7094.         move.l    _IntuitionBase(a4),a0
  7095.         cmp.l    ib_ActiveWindow(a0),d0
  7096.         beq.s    .NoCheck
  7097.         move.l    ib_ActiveWindow(a0),a0
  7098.         move.l    wd_Flags(a0),d0
  7099.         and.l    #WFLG_MENUSTATE,d0
  7100.         bne.s    .NoCheck
  7101.         move.l    _IntuitionBase(a4),a0
  7102.         move.l    ib_ActiveWindow(a0),a0
  7103.         bsr    CheckWinGads
  7104.         move.l    a0,d0
  7105.         beq.s    .NoCheck
  7106.         tst.b    StartSunMouse(a4)
  7107.         beq.s    .NoCheck
  7108.         SF    StartSunMouse(a4)
  7109.         move.b    #1,Moved(a4)            ; Set flag that already activated
  7110.         move.l    IEvent(a4),a0
  7111.         move.l    #REQ_ACTIVATE,d0
  7112.         bsr.s    SendEvent
  7113.         bra.s    .NoCheck
  7114. .NoCheck1    clr.b    Moved(a4)            ; Clear flag
  7115.  
  7116. .NoCheck    move.l    IEvent(a4),a0            ; Check if one second
  7117.         lea    ie_TimeStamp(a0),a1        ; has elapsed since last
  7118.         move.l    TV_SECS(a1),d1            ; signal
  7119.         cmp.l    OldTimeSig(a4),d1
  7120.         beq.s    NoTimerEvent
  7121.         move.l    d1,OldTimeSig(a4)        ; put the message
  7122.         move.l    #REQ_TIMER,d0
  7123.         bsr.s    SendEvent
  7124.  
  7125. NoTimerEvent    move.l    IEvent(a4),a0            ; Try to get next event linked
  7126.         move.l    ie_NextEvent(a0),d0        ; to this one
  7127.         beq.s    NoEvent                ; No other one -> that`s it
  7128.         move.l    d0,IEvent(a4)            ; Store address
  7129.         bra    EventLoop            ; Loop
  7130.  
  7131. NoEvent        SF    Cycled(a4)
  7132.         movem.l    (sp)+,RegsAll
  7133.         move.l    a0,d0                ; Rstore pointer to "new" events
  7134.         rts
  7135. FKeyQualFlags    dc.w    0,0
  7136.         dc.w    IEQUALIFIER_LSHIFT,IEQUALIFIER_RSHIFT
  7137.         dc.w    IEQUALIFIER_LALT,IEQUALIFIER_RALT
  7138.         dc.w    IEQUALIFIER_CONTROL,-1
  7139. AudioName    dc.b    "audio.device",0
  7140.         EVEN
  7141.  
  7142.  
  7143.  
  7144. **********************************************************************
  7145. *      Append the current event to a message and send that one       *
  7146. *                        to the event handler                        *
  7147. **********************************************************************
  7148. SendEvent    movem.l    d0/a0,-(sp)
  7149.         move.l    CheckerProc(a4),a1
  7150.         move.l    #31,d0
  7151.         CALLSYS    SetTaskPri
  7152.         move.l    d0,d6
  7153.         movem.l    (sp)+,d0/a0
  7154.         lea    EventPool(a4),a1        ; Find free entry
  7155.         moveq    #MAXEVENTS-1,d7
  7156. .Find        tst.l    LN_NAME(a1)
  7157.         bne.s    .GoOn
  7158.         move.l    d0,LN_NAME(a1)
  7159.         lea    req_IEvent(a1),a1
  7160.         moveq    #(ie_SIZEOF>>1)-1,d5
  7161. .CopyEvent    move.w    (a0)+,(a1)+
  7162.         dbf    d5,.CopyEvent
  7163.         move.l    CheckerProc(a4),a1
  7164.         move.l    EventSigFlag(a4),d0
  7165.         CALLSYS    Signal
  7166.         bra.s    .End
  7167. .GoOn        lea    req_SIZEOF(a1),a1
  7168.         dbf    d7,.Find
  7169. .End        move.l    d6,d0
  7170.         move.l    CheckerProc(a4),a1
  7171.         CALLSYS    SetTaskPri
  7172.         rts
  7173.  
  7174.  
  7175.  
  7176.  
  7177.  
  7178. **********************************************************************
  7179. *             Wait until remakes on clockwindow are made             *
  7180. **********************************************************************
  7181. ClockRemake    move.l    ClockHandle(a4),a0        ; Wait until window popped up
  7182.         move.l    wd_UserPort(a0),a0
  7183.         CALLSYS    WaitPort
  7184. .Loop        move.l    ClockHandle(a4),a0
  7185.         move.l    wd_UserPort(a0),a0
  7186.         DOLIB    GetMsg
  7187.         tst.l    d0
  7188.         beq.s    .End
  7189.         move.l    d0,a1
  7190.         DOLIB    ReplyMsg
  7191.         bra.s    .Loop
  7192. .End        rts
  7193.  
  7194.  
  7195.  
  7196. **********************************************************************
  7197. *                          Reset the timers                          *
  7198. **********************************************************************
  7199. ResetTimer    lea    ie_TimeStamp(a0),a0
  7200.         move.l    TV_SECS(a0),d0            ; Get current seconds
  7201.         move.l    d0,d1
  7202.         add.l    ScreenTime(a4),d0        ; add delay for screen blank
  7203.         move.l    d0,ScreenOff(a4)
  7204.         add.l    MouseTime(a4),d1        ; add delay for mouse blank
  7205.         move.l    d1,MouseOff(a4)
  7206.         clr.b    TimeReset(a4)
  7207.         rts
  7208.  
  7209.  
  7210.  
  7211. **********************************************************************
  7212. *                          Blank the mouse                           *
  7213. **********************************************************************
  7214. OffMouse    tst.b    MouseIsOff(a4)
  7215.         bne.s    .AlreadyOff
  7216.         sub.l    a0,a0
  7217.         lea    MySprite(pc),a1
  7218.         lea    NoSpriteDat,a2
  7219.         RELLIB    ChangeSprite,_GfxBase
  7220.         move.b    #1,MouseIsOff(a4)
  7221. .AlreadyOff    rts
  7222. MySprite    ds.l    3
  7223.  
  7224.  
  7225.  
  7226.  
  7227. **********************************************************************
  7228. *                           UnBlank mouse                            *
  7229. **********************************************************************
  7230. OnMouse        tst.b    MouseIsOff(a4)
  7231.         beq.s    .End
  7232.         RELLIB    RethinkDisplay,_IntuitionBase
  7233.         clr.b    MouseIsOff(a4)
  7234. .End        rts
  7235.  
  7236.  
  7237.  
  7238.  
  7239.  
  7240. **********************************************************************
  7241. *                     UnBlank/UnDimm the Screen                      *
  7242. **********************************************************************
  7243. OnScreen    bsr    GetSemaphore
  7244.         tst.b    ScreenDimm(a4)
  7245.         beq.s    .UnDimm
  7246.         tst.l    DimmBase(a4)
  7247.         beq.s    .End
  7248.  
  7249.         moveq    #0,d0                ; Check if screen to be undimmed
  7250.         RELLIB    LockIBase,_IntuitionBase    ; is still there
  7251.         move.l    d0,d7
  7252.  
  7253.         move.l    ib_FirstScreen(a6),a3        ; Get frontmost screen
  7254.  
  7255.         move.l    DimmBase(a4),a2
  7256. .ScreenLoop    move.l    dm_Screen(a2),a0
  7257.         move.l    a0,d0
  7258.         beq.s    .NoMoreScrs
  7259.         move.l    a3,a1
  7260. .CheckScreen    move.l    a1,d0
  7261.         beq.s    .ScreenNotThere
  7262.         cmp.l    a0,a1
  7263.         bne.s    .NotEqual
  7264.         lea    sc_ViewPort(a1),a0
  7265.         lea    dm_Colors(a2),a1
  7266.         moveq    #32,d0
  7267.         RELLIB    LoadRGB4,_GfxBase
  7268.         bra.s    .ScreenNotThere
  7269. .NotEqual    move.l    sc_NextScreen(a1),a1
  7270.         bra.s    .CheckScreen
  7271. .ScreenNotThere    lea    dm_SIZEOF(a2),a2
  7272.         bra.s    .ScreenLoop
  7273.  
  7274. .NoMoreScrs    move.l    d7,a0
  7275.         RELLIB    UnlockIBase,_IntuitionBase
  7276.  
  7277.         move.l    DimmBase(a4),a1
  7278.         CALLSYS    FreeVec
  7279.         clr.l    DimmBase(a4)
  7280.         bra.s    .End
  7281.  
  7282. .UnDimm        tst.l    BlankScrHandle(a4)            ; Close blank-screen if there
  7283.         beq.s    .End
  7284.         move.l    BlankScrHandle(a4),a0
  7285.         RELLIB    CloseScreen,_IntuitionBase
  7286.         clr.l    BlankScrHandle(a4)
  7287. .End        bsr    FreeSemaphore
  7288.         rts
  7289.  
  7290.  
  7291.  
  7292.  
  7293. **********************************************************************
  7294. *                       Blank/Dimm the screen                        *
  7295. **********************************************************************
  7296. OffScreen    bsr    GetSemaphore
  7297.         tst.b    ScreenDimm(a4)            ; To be dimmed ?
  7298.         beq    .NoDimm
  7299.         tst.l    BlankScrHandle(a4)        ; Blank Screen there ?
  7300.         beq.s    .NoBlankOff
  7301.         move.l    BlankScrHandle(a4),a0        ; Close it first
  7302.         RELLIB    CloseScreen,_IntuitionBase
  7303.         clr.l    BlankScrHandle(a4)
  7304. .NoBlankOff    tst.l    DimmBase(a4)            ; Already dimmed ?
  7305.         bne    .EndDimm
  7306.  
  7307.         moveq    #0,d0                ; Lock Base
  7308.         RELLIB    LockIBase,_IntuitionBase
  7309.         move.l    d0,-(sp)
  7310.         move.l    ib_FirstScreen(a6),a3
  7311.         move.l    a3,a0
  7312.  
  7313.         moveq    #1,d0                ; Calc number of screens
  7314. .CalcScreens    move.l    a0,d1
  7315.         beq.s    .NoMoreScreens
  7316.         addq.l    #1,d0
  7317.         move.l    sc_NextScreen(a0),a0
  7318.         bra.s    .CalcScreens
  7319.  
  7320. .NoMoreScreens    mulu    #dm_SIZEOF,d0            ; Get buffer for screens
  7321.         move.l    #MEMF_CLEAR,d1
  7322.         CALLSYS    AllocVec
  7323.         move.l    d0,DimmBase(a4)
  7324.         beq    .DimmError
  7325.  
  7326.         move.l    d0,a2                ; Get pointer to buffer
  7327.  
  7328. .GetColors    move.l    a3,d0
  7329.         beq.s    .GotColors            ; available to the structure
  7330.         move.l    a3,dm_Screen(a2)        ; allocated
  7331.         lea    sc_ViewPort(a3),a3
  7332.         move.l    vp_ColorMap(a3),a3
  7333.         move.w    cm_Count(a3),dm_NumCols(a2)
  7334.         move.l    a2,a1
  7335.         moveq    #31,d7
  7336.         moveq    #0,d6
  7337. .LoopColors    move.l    a3,a0
  7338.         move.l    d6,d0
  7339.         move.l    a1,-(sp)
  7340.         RELLIB    GetRGB4,_GfxBase
  7341.         move.l    (sp)+,a1
  7342.         move.w    d0,dm_Colors(a1)
  7343.         move.w    d0,dm_Dimmed(a1)
  7344.         addq.l    #2,a1
  7345.         addq.l    #1,d6
  7346.         dbf    d7,.LoopColors
  7347.         move.l    dm_Screen(a2),a3
  7348.         lea    dm_SIZEOF(a2),a2
  7349.         move.l    sc_NextScreen(a3),a3
  7350.         bra.s    .GetColors
  7351.  
  7352. .GotColors    move.l    DimmBase(a4),a2            ; Dimm the colors by the given amount
  7353. .ScreenLoop    move.w    dm_NumCols(a2),d7
  7354.         subq.w    #1,d7
  7355.         lea    dm_Dimmed(a2),a3
  7356. .RemakeAll    move.l    DimmValue(a4),d4
  7357. .RemakeCols    move.w    (a3),d0
  7358.         move.w    d0,d1
  7359.         move.w    d0,d2
  7360.         and.w    #$0f00,d0
  7361.         and.w    #$00f0,d1
  7362.         and.w    #$000f,d2
  7363.         lsr.w    #8,d0
  7364.         lsr.w    #4,d1
  7365.         subq.w    #1,d0                ; Sub one from the red part
  7366.         bge.s    .GoRed
  7367.         moveq    #0,d0                ; If <0 clear red
  7368. .GoRed        subq.w    #1,d4                ; On value done
  7369.         ble.s    .GoBlue                ; Noe more left ? -> Quit
  7370.         subq.w    #1,d1                ; Now go for greem
  7371.         bge.s    .GoGreen
  7372.         moveq    #0,d1
  7373. .GoGreen    subq.w    #1,d4                ; Done ???
  7374.         ble.s    .GoBlue
  7375.         subq.w    #1,d2                ; Go for blue
  7376.         bge.s    .GoBlue
  7377.         moveq    #0,d2
  7378. .GoBlue        lsl.w    #8,d0                ; reconstruct new color
  7379.         lsl.w    #4,d1
  7380.         or.w    d1,d2
  7381.         or.w    d0,d2
  7382.         move.w    d2,(a3)                ; and write it back
  7383.         subq.w    #1,d4
  7384.         bgt.s    .RemakeCols
  7385.         addq.l    #2,a3
  7386.         dbf    d7,.RemakeAll
  7387.         move.l    dm_Screen(a2),a0        ; Load new colors
  7388.         lea    sc_ViewPort(a0),a0
  7389.         lea    dm_Dimmed(a2),a1
  7390.         move.w    dm_NumCols(a2),d0
  7391.         RELLIB    LoadRGB4,_GfxBase
  7392.         lea    dm_SIZEOF(a2),a2
  7393.         tst.l    dm_Screen(a2)
  7394.         bne.s    .ScreenLoop
  7395.  
  7396. .DimmError    move.l    (sp)+,a0
  7397.         RELLIB    UnlockIBase,_IntuitionBase
  7398. .EndDimm    bsr    FreeSemaphore
  7399.         rts
  7400.  
  7401. .NoDimm        tst.l    BlankScrHandle(a4)        ; Screen already blanked ?
  7402.         bne.s    .End                ; Yep -> pop it to front
  7403.         moveq    #0,d0
  7404.         RELLIB    LockIBase,_IntuitionBase    ; Get DisplayID of active screen
  7405.         move.l    ib_ActiveScreen(a6),a2
  7406.         move.l    d0,a0
  7407.         DOLIB    UnlockIBase
  7408.         lea    sc_ViewPort(a2),a0
  7409.         RELLIB    GetVPModeID,_GfxBase
  7410.         cmp.l    #INVALID_ID,d0
  7411.         beq.s    .EndIt
  7412.         move.l    d0,BlankScrTags+4
  7413.         sub.l    a0,a0
  7414.         lea    BlankScrTags(pc),a1
  7415.         RELLIB    OpenScreenTagList,_IntuitionBase
  7416.         move.l    d0,BlankScrHandle(a4)
  7417.         beq.s    .EndIt
  7418.         bsr    OffMouse            ; Disable mouse
  7419.         bsr    FreeSemaphore
  7420.         rts
  7421. .End        move.l    BlankScrHandle(a4),a0        ; Get screen to front :-)
  7422.         RELLIB    ScreenToFront,_IntuitionBase
  7423.         bsr    OffMouse
  7424. .EndIt        bsr    FreeSemaphore
  7425.         rts
  7426. BlankScrTags    dc.l    SA_DisplayID,DEFAULT_MONITOR_ID
  7427.         dc.l    SA_Depth,1
  7428.         dc.l    SA_Colors,BlankCols
  7429.         dc.l    SA_Quiet,-1
  7430.         dc.l    TAG_DONE
  7431. BlankCols    dc.w    0,0,0,0,0,0,0,0,-1,0,0,0
  7432.  
  7433.  
  7434.  
  7435.  
  7436. **********************************************************************
  7437. *                   This is the activation-routine                   *
  7438. **********************************************************************
  7439. Activate    bsr    GetSemaphore
  7440.         movem.l    d0-d7/a0-a6,-(sp)
  7441.         link    a5,#-(180+80)
  7442.         tst.w    RequestsOpen(a4)
  7443.         bne    .NotAct
  7444.  
  7445.         RELLIB    FindWindow,_KCXBase
  7446.         tst.l    d0
  7447.         beq    .NotAct
  7448.  
  7449.         movem.l    d0/a0,-(sp)
  7450.         CALLSYS    Forbid
  7451.         moveq    #0,d0
  7452.         RELLIB    LockIBase,_IntuitionBase
  7453.  
  7454.         move.l    ib_ActiveWindow(a6),a2        ; First look if it`s a "locked" window
  7455.  
  7456.         move.l    d0,a0
  7457.         DOLIB    UnlockIBase
  7458.  
  7459.         move.l    a2,a0                ; Active window has an active
  7460.         bsr    CheckWinGads            ; String Gadget ?
  7461.         move.l    a0,d0
  7462.         beq    .GotWindow
  7463.  
  7464. .NoStrGad    move.l    wd_UserPort(a2),d0        ; Try to get UserPort
  7465.         beq    .NoWinPort
  7466.         move.l    d0,a0
  7467.         move.l    MP_SIGTASK(a0),d0        ; Get task of window
  7468.         beq    .NoWinPort
  7469.         move.l    d0,a3
  7470.         moveq    #-1,d7
  7471.         moveq    #1,d5
  7472.         cmp.b    #NT_PROCESS,LN_TYPE(a3)        ; Is it a process ?
  7473.         bne.s    .IsTask                ; Nope go on
  7474.         moveq    #0,d5
  7475.         tst.l    pr_TaskNum(a3)            ; Got a task number ?
  7476.         beq.s    .IsTask                ; Nope -> is task
  7477.         move.l    pr_CLI(a3),d0            ; Have a cli ?
  7478.         beq.s    .IsTask                ; Nope -> is task
  7479.         lsl.l    #2,d0
  7480.         move.l    d0,a0
  7481.         tst.l    cli_Module(a0)            ; Got a module ?
  7482.         beq.s    .IsTask                ; Nope -> is task
  7483.         move.l    cli_CommandName(a0),d0        ; Get name of process
  7484.         lsl.l    #2,d0
  7485.         move.l    d0,a0
  7486.         moveq    #0,d7
  7487.         move.b    (a0)+,d7            ; Get Length of taskname
  7488.         lea    -(180+80)(a5),a1
  7489.         bsr    StrNCpy                ; Copy name
  7490.         bra.s    .GoOnName
  7491. .IsTask        move.l    LN_NAME(a3),a0            ; Get name of task
  7492.         lea    -(180+80)(a5),a1
  7493.         bsr    StrCpy                ; Copy name
  7494. .GoOnName    lea    TaskWinBase(a4),a3
  7495.         TSTLIST    a3
  7496.         beq.s    .NoWinPort
  7497.         move.l    LH_HEAD(a3),a3
  7498. .LoopTasks    move.l    a3,d0
  7499.         beq.s    .NoWinPort
  7500.         lea    lw_Name(a3),a0            ; Get name
  7501.         tst.b    d5
  7502.         beq.s    .IsProc
  7503.         lea    -(180+80)(a5),a1
  7504.         bsr    StrCmp
  7505.         tst.l    d0
  7506.         bne.s    .NotSameTask
  7507.         movem.l    (sp)+,d0/a0
  7508.         sub.l    a0,a0
  7509.         bra    .GotWindow
  7510. .IsProc        move.l    a0,d1
  7511.         lea    -180(a5),a0            ; Get buffer for pattern
  7512.         move.l    a0,d2
  7513.         move.l    #180,d3
  7514.         RELLIB    ParsePatternNoCase,_DOSBase    ; Tokenize pattern
  7515.         lea    -180(a5),a0            ; Check if name of task matches
  7516.         move.l    a0,d1
  7517.         lea    -(180+80)(a5),a0
  7518.         move.l    a0,d2
  7519.         DOLIB    MatchPatternNoCase
  7520.         tst.l    d0
  7521.         beq.s    .NotSameTask
  7522.         movem.l    (sp)+,d0/a0
  7523.         sub.l    a0,a0
  7524.         bra.s    .GotWindow
  7525. .NotSameTask    SUCC    a3,a3
  7526.         bra.s    .LoopTasks
  7527.  
  7528. .NoWinPort    move.l    wd_Title(a2),d0            ; Get name of window
  7529.         beq.s    .DoAct
  7530.         move.l    d0,a2
  7531.         lea    WindowBase(a4),a3        ; Get address of window list
  7532.         TSTLIST    a3
  7533.         beq.s    .DoAct
  7534.         move.l    LH_HEAD(a3),a3
  7535. .LoopWins    move.l    a3,d0
  7536.         beq.s    .DoAct
  7537.         lea    lw_Name(a3),a0            ; Get name
  7538.         move.l    a0,d1
  7539.         lea    -180(a5),a0            ; Get buffer for pattern
  7540.         move.l    a0,d2
  7541.         move.l    #180,d3
  7542.         RELLIB    ParsePatternNoCase,_DOSBase    ; Tokenize pattern
  7543.         lea    -180(a5),a0            ; Check if title of window matches
  7544.         move.l    a0,d1
  7545.         move.l    a2,d2
  7546.         DOLIB    MatchPatternNoCase
  7547.         tst.l    d0
  7548.         beq.s    .NotSameWin
  7549.         movem.l    (sp)+,d0/a0
  7550.         sub.l    a0,a0
  7551.         bra.s    .GotWindow
  7552. .NotSameWin    SUCC    a3,a3
  7553.         bra.s    .LoopWins
  7554.  
  7555. .DoAct        movem.l    (sp)+,d0/a0
  7556.         move.l    d0,a1
  7557.         move.l    lr_Window(a1),a1
  7558.         move.l    _IntuitionBase(a4),a2
  7559.         cmp.l    ib_ActiveWindow(a2),a1
  7560.         bne.s    .GoOn
  7561.         sub.l    a0,a0
  7562.         bra.s    .GotWindow
  7563. .GoOn        move.l    d0,a0
  7564.         move.l    lr_Window(a0),a0
  7565. .GotWindow    CALLSYS    Permit
  7566.         move.l    a0,d0
  7567.         beq.s    .NotAct
  7568.         RELLIB    ActivateWindow,_IntuitionBase    ; activate window
  7569. .NotAct        unlk    a5
  7570.         movem.l    (sp)+,d0-d7/a0-a6
  7571.         bra    FreeSemaphore
  7572.  
  7573.  
  7574.  
  7575.  
  7576. **********************************************************************
  7577. *           Checks for any active gadgets within a window            *
  7578. **********************************************************************
  7579. CheckWinGads    movem.l    d1/a1,-(sp)
  7580.         move.l    wd_FirstGadget(a0),a1        ; First gadget of window
  7581.  
  7582. .CheckGadgets    move.l    a1,d1
  7583.         beq.s    .GadgetsChecked
  7584.  
  7585.         move.w    gg_GadgetType(a1),d1        ; Is it a string-gadget ?
  7586.         and.w    #STRGADGET,d1
  7587.         beq.s    .NoStrGad            ; No -> go on
  7588.  
  7589.         move.w    gg_Flags(a1),d1            ; Is it selected ?
  7590.         and.w    #GFLG_SELECTED,d1
  7591.         bne.s    .NoWindow            ; Yep -> No more actions
  7592.  
  7593. .NoStrGad    move.l    gg_NextGadget(a1),a1        ; Check all gads in window
  7594.         bra    .CheckGadgets
  7595. .NoWindow    sub.l    a0,a0
  7596. .GadgetsChecked    movem.l    (sp)+,d1/a1
  7597.         rts
  7598.  
  7599.  
  7600. **********************************************************************
  7601. *            Signal the timer process to remake the time             *
  7602. **********************************************************************
  7603. SigTime        move.l    CheckerProc(a4),a1
  7604.         move.l    #SIGTIMEREMAKE,d0
  7605.         CALLSYS    Signal
  7606.         rts
  7607.  
  7608.  
  7609. **********************************************************************
  7610. *                          Display new time                          *
  7611. **********************************************************************
  7612. SetTime        lea    MyDateTime(a4),a0        ; Get datestamp
  7613.         move.l    a0,d1
  7614.         RELLIB    DateStamp,_DOSBase
  7615.  
  7616.         lea    MyDateTime(a4),a0        ; Do the string formatings
  7617.         clr.b    dat_Flags(a0)
  7618.         lea    MyDateTime(a4),a0        ; Check for englich/german format
  7619.         cmp.w    #4,DateFormat(a4)
  7620.         blt.s    .NoDos
  7621.         move.b    #FORMAT_DOS,dat_Format(a0)
  7622.         bra.s    .GotFormat
  7623. .NoDos        tst.w    DateFormat(a4)
  7624.         beq.s    .English
  7625.         cmp.w    #2,DateFormat(a4)
  7626.         beq.s    .English
  7627.         move.b    #FORMAT_CDN,dat_Format(a0)
  7628.         bra.s    .GotFormat
  7629. .English    move.b    #FORMAT_USA,dat_Format(a0)
  7630.  
  7631. .GotFormat    clr.b    AllDateString
  7632.         lea    AllDayString(pc),a1
  7633.         move.l    a1,dat_StrDay(a0)        ; First create the whole string
  7634.         lea    AllDateString(pc),a1
  7635.         move.l    a1,dat_StrDate(a0)        ; for environment variables
  7636.         lea    AllTimeString(pc),a1
  7637.         move.l    a1,dat_StrTime(a0)
  7638.         move.l    a0,d1
  7639.         DOLIB    DateToStr
  7640.  
  7641.         lea    AllDateString(pc),a0
  7642.         bsr    CheckPoints
  7643.  
  7644.         tst.b    SetEnv(a4)            ; Write env vars
  7645.         beq.s    NoEnvTime
  7646.  
  7647.         lea    EnvDayString(pc),a1
  7648.         move.l    a1,d1                ; set env vars
  7649.         lea    AllDayString(pc),a1
  7650.         move.l    a1,d2
  7651.         moveq    #-1,d3
  7652.         move.l    #GVF_GLOBAL_ONLY,d4
  7653.         DOLIB    SetVar
  7654.         tst.l    d0
  7655.         beq.s    .Error
  7656.  
  7657.         lea    EnvDateString(pc),a1
  7658.         move.l    a1,d1
  7659.         lea    AllDateString(pc),a1
  7660.         move.l    a1,d2
  7661.         moveq    #-1,d3
  7662.         move.l    #GVF_GLOBAL_ONLY,d4
  7663.         DOLIB    SetVar
  7664.         tst.l    d0
  7665.         beq.s    .Error
  7666.  
  7667.         lea    EnvTimeString(pc),a1
  7668.         move.l    a1,d1
  7669.         lea    AllTimeString(pc),a1
  7670.         move.l    a1,d2
  7671.         moveq    #-1,d3
  7672.         move.l    #GVF_GLOBAL_ONLY,d4
  7673.         DOLIB    SetVar
  7674.         tst.l    d0
  7675.         bne.s    NoEnvTime
  7676.  
  7677. .Error        clr.b    SetEnv(a4)        ; Disable setenv if errors
  7678. NoEnvTime    clr.b    DayString        ; clear previous strings
  7679.         clr.b    DateString
  7680.         clr.b    TimeString
  7681.  
  7682.         lea    MyDateTime(a4),a0
  7683.         tst.b    ShowDay(a4)        ; Now create the rest for clock
  7684.         beq.s    .Loop3            ; display
  7685.         lea    DayString(pc),a1
  7686.         move.l    a1,dat_StrDay(a0)
  7687.         bra.s    .Loop4
  7688. .Loop3        clr.l    dat_StrDay(a0)
  7689.  
  7690. .Loop4        tst.b    ShowDate(a4)        ; Are we to show a date ?
  7691.         beq.s    .Loop5
  7692.         lea    DateString(pc),a1
  7693.         move.l    a1,dat_StrDate(a0)    ; Yep
  7694.         bra.s    .Loop6
  7695. .Loop5        clr.l    dat_StrDate(a0)        ; Nope
  7696. .Loop6        tst.b    DoShowTime(a4)        ; Show time ?
  7697.         beq.s    .Loop6a
  7698.         lea    TimeString(pc),a1
  7699.         move.l    a1,dat_StrTime(a0)
  7700.         bra.s    .Loop6b
  7701. .Loop6a        clr.l    dat_StrTime(a0)
  7702. .Loop6b        move.l    a0,d1
  7703.         DOLIB    DateToStr
  7704.         tst.l    d0
  7705.         beq    NoTime
  7706.         lea    DateString(pc),a0
  7707.         bsr    CheckPoints
  7708.  
  7709.         bsr    CheckForAlarm            ; Are we to alarm ?
  7710.  
  7711.         tst.b    ShowClock(a4)            ; Show clock ?
  7712.         beq    NoTime
  7713.  
  7714.         cmp.l    #TIMEPAGE,PageNum(a4)        ; Display normal time ?
  7715.         bgt    NoClockDisp
  7716.  
  7717.         lea    TimeFormats,a0            ; Change to different
  7718.         tst.b    ShortDay(a4)            ; time format strings
  7719.         beq.s    .Loop7
  7720.         addq.l    #8,a0                ; Use the ones with long days
  7721. .Loop7        tst.b    ShowSecs(a4)
  7722.         bne.s    .Loop8
  7723.         addq.l    #4,a0                ; use the one without secs
  7724. .Loop8        move.l    (a0),a0
  7725.         lea    FormatData(pc),a1
  7726.         lea    PutChProc(pc),a2
  7727.         lea    FinalString(a4),a3
  7728.         CALLSYS    RawDoFmt
  7729.  
  7730.         tst.b    ShowMouse(a4)            ; Show Mouse positions ?
  7731.         beq.s    .NoMousePos
  7732.         link    a5,#-(4+30)
  7733.         moveq    #0,d0
  7734.         RELLIB    LockIBase,_IntuitionBase
  7735.         move.l    d0,d7
  7736.         move.l    ib_ActiveScreen(a6),a0
  7737.         move.w    sc_MouseX(a0),-4(a5)
  7738.         move.w    sc_MouseY(a0),-2(a5)
  7739.         move.l    d7,a0
  7740.         DOLIB    UnlockIBase
  7741.         lea    MousePosForm,a0
  7742.         lea    -4(a5),a1
  7743.         lea    PutChProc(pc),a2
  7744.         lea    -(4+30)(a5),a3
  7745.         CALLSYS    RawDoFmt
  7746.         lea    -(4+30)(a5),a0
  7747.         lea    FinalString(a4),a1
  7748.         bsr    StrCat
  7749.         unlk    a5
  7750. .NoMousePos    bsr    MakeDisplay            ; Display the stuff
  7751.         bra    NoTime
  7752.  
  7753. NoClockDisp    cmp.l    #DMEMPAGE,PageNum(a4)        ; Display Chip/Fast mem seperately ?
  7754.         bne.s    NoDoubleMem
  7755.  
  7756.         move.l    #MEMF_CHIP,d1            ; Get available memory
  7757.         CALLSYS    AvailMem
  7758.         move.l    d0,ChipMem
  7759.         move.l    #MEMF_FAST,d1
  7760.         DOLIB    AvailMem
  7761.         move.l    d0,FastMem
  7762.  
  7763.         lea    FormMemString,a0        ; Format string
  7764.         lea    ChipMem,a1
  7765.         lea    PutChProc(pc),a2
  7766.         lea    FinalString(a4),a3
  7767.         DOLIB    RawDoFmt
  7768.  
  7769.         bsr    MakeDisplay            ; Display
  7770.         bra    NoTime
  7771.  
  7772. NoDoubleMem    cmp.l    #TMEMPAGE,PageNum(a4)        ; Display total memory ?
  7773.         bne.s    NoTotalMem
  7774.  
  7775.         move.l    #MEMF_CHIP,d1            ; Calc total memory
  7776.         CALLSYS    AvailMem
  7777.         move.l    d0,d7
  7778.         move.l    #MEMF_FAST,d1
  7779.         DOLIB    AvailMem
  7780.         add.l    d0,d7
  7781.         move.l    d7,TotalMem
  7782.  
  7783.         LOCLEA    FormTMemString,a0
  7784.         lea    TotalMem,a1
  7785.         lea    PutChProc(pc),a2
  7786.         lea    FinalString(a4),a3
  7787.         DOLIB    RawDoFmt
  7788.  
  7789.         bsr    MakeDisplay
  7790.         bra    NoTime
  7791.  
  7792. NoTotalMem    cmp.l    #TIMEMEMPAGE,PageNum(a4)    ; Display time and memory ?
  7793.         bne    NoDoublePage
  7794.  
  7795.         lea    TimeFormats,a0            ; Change to different
  7796.         tst.b    ShortDay(a4)            ; time format strings
  7797.         beq.s    .Loop7
  7798.         addq.l    #8,a0                ; Use the ones with long days
  7799. .Loop7        tst.b    ShowSecs(a4)
  7800.         bne.s    .Loop8
  7801.         addq.l    #4,a0                ; use the one without secs
  7802. .Loop8        move.l    (a0),a0
  7803.         lea    FormatData(pc),a1
  7804.         lea    PutChProc(pc),a2
  7805.         lea    FinalString(a4),a3
  7806.         CALLSYS    RawDoFmt
  7807.  
  7808.         move.l    #MEMF_CHIP,d1            ; Get available memory
  7809.         CALLSYS    AvailMem
  7810.         lsr.l    #8,d0
  7811.         lsr.l    #2,d0
  7812.         move.l    d0,ChipMem
  7813.         move.l    #MEMF_FAST,d1
  7814.         DOLIB    AvailMem
  7815.         lsr.l    #8,d0
  7816.         lsr.l    #2,d0
  7817.         move.l    d0,FastMem
  7818.  
  7819.         link    a5,#-80
  7820.  
  7821.         lea    DoubleMemString,a0        ; Format string
  7822.         lea    ChipMem,a1
  7823.         lea    PutChProc(pc),a2
  7824.         lea    -80(a5),a3
  7825.         DOLIB    RawDoFmt
  7826.  
  7827.         lea    -80(a5),a0
  7828.         lea    FinalString(a4),a1
  7829.         bsr    StrCat
  7830.         unlk    a5
  7831.  
  7832.         bsr    MakeDisplay
  7833.         bra    NoTime
  7834.  
  7835. NoDoublePage    cmp.l    #GMEMPAGE,PageNum(a4)        ; Display fillgauge
  7836.         bne    NoGfxMem
  7837.  
  7838.         link    a5,#-4
  7839.         bsr    LockScreen
  7840.         tst.l    d0
  7841.         bne.s    .GoOn
  7842.         clr.l    PageNum(a4)
  7843.         bra    NoGfxMem
  7844.  
  7845. .GoOn        move.l    MyRastPort(a4),a1
  7846.         move.l    TextBackPen(a4),d0
  7847.         RELLIB    SetRast,_GfxBase
  7848.  
  7849.         move.l    #MEMF_CHIP,d1            ; Calc total memory
  7850.         CALLSYS    AvailMem
  7851.         move.l    d0,d7
  7852.         move.l    #MEMF_FAST,d1
  7853.         DOLIB    AvailMem
  7854.         add.l    d7,d0
  7855.         move.l    MaxMem(a4),d7
  7856.         sub.l    d0,d7
  7857.  
  7858.         move.l    MyRastPort(a4),a1        ; Get length of E and F
  7859.         LOCLEA    EString(pc),a0            ; chars
  7860.         moveq    #1,d0
  7861.         RELLIB    TextLength,_GfxBase
  7862.         move.l    d0,EWidth(a4)
  7863.         move.l    d0,d5
  7864.         move.l    MyRastPort(a4),a1
  7865.         LOCLEA    FString(pc),a0
  7866.         moveq    #1,d0
  7867.         DOLIB    TextLength
  7868.         move.l    d0,FWidth(a4)
  7869.         add.l    d5,d0                ; d0 length of both
  7870.         add.l    MaxBarLen(a4),d0
  7871.         addq.l    #4,d0
  7872.         move.l    d0,BlitWidth(a4)
  7873.         moveq    #0,d2
  7874.         move.l    -4(a5),a0
  7875.         move.w    sc_Width(a0),d2
  7876.         sub.l    #DEPTHWIDTH,d2
  7877.         sub.l    d0,d2
  7878.         move.l    d2,LeftEdge(a4)
  7879.         move.l    MaxBarLen(a4),d0        ; Get maximum length of bar
  7880.         move.l    d7,d1
  7881.         RELLIB    UMult32,_UtilityBase
  7882.         move.l    MaxMem(a4),d1
  7883.         DOLIB    UDivMod32
  7884.         move.l    d0,d5                ; D5 = Length of gauge
  7885.  
  7886.         move.l    MyRastPort(a4),a1
  7887.         move.l    TextFrontPen(a4),d0
  7888.         RELLIB    SetAPen,_GfxBase
  7889.  
  7890.         move.l    MyRastPort(a4),a1        ; Write E
  7891.         moveq    #0,d1
  7892.         move.l    MyFont(a4),a0
  7893.         move.w    tf_Baseline(a0),d1
  7894.         moveq    #0,d0
  7895.         DOLIB    Move
  7896.         move.l    MyRastPort(a4),a1
  7897.         LOCLEA    EString(pc),a0
  7898.         moveq    #1,d0
  7899.         DOLIB    Text
  7900.  
  7901.         move.l    MyRastPort(a4),a1        ; Draw "non-filled" rec
  7902.         move.l    GaugeBackPen(a4),d0
  7903.         DOLIB    SetAPen
  7904.  
  7905.         move.l    MyRastPort(a4),a1
  7906.         move.l    EWidth(a4),d0
  7907.         addq.l    #2,d0
  7908.         moveq    #0,d1
  7909.         move.l    d0,d2
  7910.         add.l    MaxBarLen(a4),d2
  7911.         moveq    #0,d3
  7912.         move.l    MyFont(a4),a0
  7913.         move.w    tf_YSize(a0),d3
  7914.         subq.l    #1,d3
  7915.         DOLIB    RectFill
  7916.  
  7917.         move.l    MyRastPort(a4),a1        ; Draw gauge
  7918.         move.l    GaugeFrontPen(a4),d0
  7919.         DOLIB    SetAPen
  7920.  
  7921.         move.l    MyRastPort(a4),a1
  7922.         move.l    EWidth(a4),d0
  7923.         addq.l    #2,d0
  7924.         moveq    #0,d1
  7925.         move.l    d5,d2
  7926.         add.l    d0,d2
  7927.         moveq    #0,d3
  7928.         move.l    MyFont(a4),a0
  7929.         move.w    tf_YSize(a0),d3
  7930.         subq.l    #1,d3
  7931.         DOLIB    RectFill
  7932.  
  7933.         move.l    MyRastPort(a4),a1        ; Draw F
  7934.         move.l    TextFrontPen(a4),d0
  7935.         DOLIB    SetAPen
  7936.  
  7937.         move.l    MyRastPort(a4),a1
  7938.         move.l    EWidth(a4),d0
  7939.         addq.l    #4,d0
  7940.         add.l    MaxBarLen(a4),d0
  7941.         move.l    MyFont(a4),a0
  7942.         moveq    #0,d1
  7943.         move.w    tf_Baseline(a0),d1
  7944.         DOLIB    Move
  7945.         move.l    MyRastPort(a4),a1
  7946.         LOCLEA    FString(pc),a0
  7947.         moveq    #1,d0
  7948.         DOLIB    Text
  7949.  
  7950.         move.l    MyRastPort(a4),a1        ; Reset color for our RastPort
  7951.         moveq    #0,d0
  7952.         DOLIB    SetAPen
  7953.  
  7954.         tst.b    ClockWin(a4)            ; Window active ?
  7955.         beq.s    TitleGauge
  7956.  
  7957.         move.l    BlitWidth(a4),d6
  7958.         bsr    OpenClockWin
  7959.         tst.l    d0
  7960.         beq    NoTime
  7961.         bra.s    .NoClear
  7962. .Clear        move.l    ClockHandle(a4),a0
  7963.         tst.l    wd_Title(a0)            ; Window-Title already cleard ?
  7964.         beq.s    .NoClear
  7965.         sub.l    a1,a1                ; Clear window-title
  7966.         suba.l    a2,a2
  7967.         subq.w    #1,a2
  7968.         RELLIB    SetWindowTitles,_IntuitionBase
  7969.  
  7970. .NoClear    move.l    ClockHandle(a4),a1        ; Blit gauge into window-title
  7971.         move.l    wd_RPort(a1),a1
  7972.         move.l    #DEPTHWIDTH,d2
  7973.         bra.s    DoGauge
  7974.  
  7975. TitleGauge    bsr    CloseClockWin
  7976.         move.l    -4(a5),a1            ; Blit gauge into title/window
  7977.         move.l    sc_BarLayer(a1),a1
  7978.         move.l    lr_rp(a1),a1
  7979.         move.l    LeftEdge(a4),d2
  7980.  
  7981. DoGauge        move.l    MyRastPort(a4),a0
  7982.         moveq    #0,d0
  7983.         moveq    #0,d1
  7984.         moveq    #1,d3
  7985.         move.l    BlitWidth(a4),d4
  7986.         moveq    #0,d5
  7987.         move.w    BitMapHeight(a4),d5
  7988.         move.l    #$c0,d6
  7989.         RELLIB    ClipBlit,_GfxBase
  7990.  
  7991.         bsr    UnlockScreen
  7992.         unlk    a5
  7993.         bra.s    NoTime
  7994.  
  7995. NoGfxMem    cmp.l    #ONLINEPAGE,PageNum(a4)        ; Display online-time ?
  7996.         bne.s    NoOnlinePage            ; Nope -> go on
  7997.         LOCLEA    OnlineFormStr(pc),a0        ; Copy online string
  7998.         lea    FinalString(a4),a1
  7999.         bsr    StrCpy
  8000.         lea    OnlineString(pc),a0        ; Concat time string
  8001.         lea    FinalString(a4),a1
  8002.         bsr    StrCat
  8003.         bsr.s    MakeDisplay
  8004.         bra.s    NoTime
  8005.  
  8006. NoOnlinePage    cmp.l    #SNAPMEMPAGE,PageNum(a4)    ; Display snapped memory ?
  8007.         bne.s    NoTime
  8008.         LOCLEA    FormSnapMemStr,a0        ; Format string
  8009.         lea    ThisChip,a1
  8010.         lea    PutChProc(pc),a2
  8011.         lea    FinalString(a4),a3
  8012.         CALLSYS    RawDoFmt
  8013.         bsr.s    MakeDisplay            ; Display
  8014. NoTime        rts
  8015. EnvDayString    dc.b    "DAY",0
  8016. EnvDateString    dc.b    "DATE",0
  8017. EnvTimeString    dc.b    "TIME",0
  8018.         EVEN
  8019.  
  8020.  
  8021. **********************************************************************
  8022. *              Convert "-" within date to "." if needed              *
  8023. **********************************************************************
  8024. CheckPoints    tst.b    (a0)
  8025.         beq.s    .NoFormat
  8026.         cmp.w    #4,DateFormat(a4)
  8027.         beq.s    .NoFormat
  8028.         cmp.w    #5,DateFormat(a4)
  8029.         beq.s    .DosPoint
  8030.         cmp.w    #1,DateFormat(a4)
  8031.         ble.s    .NoFormat
  8032.         move.b    #'.',2(a0)
  8033.         move.b    #'.',5(a0)
  8034.         bra.s    .NoFormat
  8035. .DosPoint    move.b    #'.',2(a0)
  8036.         move.b    #'.',6(a0)
  8037. .NoFormat    rts
  8038.  
  8039.  
  8040.  
  8041.  
  8042. **********************************************************************
  8043. *                Make up the display for clock/memory                *
  8044. **********************************************************************
  8045. MakeDisplay    lea    FinalString(a4),a0        ; Get length of time string
  8046.         bsr    StrLen
  8047.         move.l    d0,d7
  8048.         move.l    MyRastPort(a4),a1        ; Get width of string (pixels)
  8049.         RELLIB    TextLength,_GfxBase
  8050.         move.l    d0,d6
  8051.  
  8052.         tst.b    ClockWin(a4)            ; Display in window ?
  8053.         beq.s    DisplayInTitle            ; Nope -> do it in title
  8054.  
  8055.         bsr    OpenClockWin
  8056.         tst.l    d0
  8057.         beq.s    .NoDisplay
  8058.  
  8059.         move.l    ClockHandle(a4),a0        ; Set new title of window
  8060.         lea    FinalString(a4),a1
  8061.         suba.l    a2,a2
  8062.         subq.w    #1,a2
  8063.         RELLIB    SetWindowTitles,_IntuitionBase
  8064. .NoDisplay    rts
  8065.  
  8066. DisplayInTitle    link    a5,#-4
  8067.         bsr    LockScreen
  8068.         tst.l    d0
  8069.         beq    NoDisplay
  8070.  
  8071.         bsr    CloseClockWin
  8072.  
  8073.         move.l    MyRastPort(a4),a1        ; Clear rastport
  8074.         move.l    TextBackPen(a4),d0
  8075.         RELLIB    SetRast,_GfxBase
  8076.  
  8077.         move.l    MyRastPort(a4),a1        ; Set text pen
  8078.         move.l    TextFrontPen(a4),d0
  8079.         DOLIB    SetAPen
  8080.  
  8081.         moveq    #0,d1                ; Move cursor to position
  8082.         move.l    MyFont(a4),a0
  8083.         move.w    tf_Baseline(a0),d1
  8084.         move.l    MyRastPort(a4),a1
  8085.         moveq    #0,d0
  8086.         DOLIB    Move
  8087.  
  8088.         move.l    MyRastPort(a4),a1        ; Draw string
  8089.         lea    FinalString(a4),a0
  8090.         move.l    d7,d0
  8091.         DOLIB    Text
  8092.  
  8093.         moveq    #0,d2
  8094.         move.l    -4(a5),a0
  8095.         move.w    sc_Width(a0),d2            ; Get width of screen
  8096.         sub.l    #DEPTHWIDTH,d2            ; Skip depth gadget
  8097.         sub.l    d6,d2                ; Skip width of string
  8098.         move.l    d2,LeftEdge(a4)            ; Store new X-Position in TitleBar
  8099.         move.l    d6,d4
  8100.         add.w    #DEPTHWIDTH,d6
  8101.         cmp.w    BitMapWidth(a4),d6        ; If width to be blitted is
  8102.         ble.s    .End                ; > Plane width : Skip some pixels
  8103.         move.w    BitMapWidth(a4),d4
  8104.         sub.w    #DEPTHWIDTH,d4
  8105. .End        move.l    d4,BlitWidth(a4)            ; Store width of string
  8106.  
  8107.         move.l    MyRastPort(a4),a0        ; Blit our rastport into
  8108.         moveq    #0,d0                ; rastport of layer which
  8109.         moveq    #0,d1                ; is the titlebar
  8110.         move.l    -4(a5),a1
  8111.         move.l    sc_BarLayer(a1),a1
  8112.         move.l    lr_rp(a1),a1
  8113.         move.l    #1,d3
  8114.         moveq    #0,d5
  8115.         move.w    BitMapHeight(a4),d5
  8116.         move.l    #$c0,d6
  8117.         DOLIB    ClipBlit
  8118.  
  8119. NoDisplay    bsr    UnlockScreen
  8120.         unlk    a5
  8121.         rts
  8122.  
  8123.  
  8124.  
  8125.  
  8126. **********************************************************************
  8127. *                   Clears the workbench titlebar                    *
  8128. **********************************************************************
  8129. ClearTitleBar    tst.l    CheckerProc(a4)
  8130.         beq.s    .Error
  8131.         link    a5,#-4
  8132.         bsr    LockScreen
  8133.         tst.l    d0
  8134.         beq.s    .End
  8135.  
  8136.         RELLIB    WaitTOF,_GfxBase
  8137.  
  8138.         move.l    MyRastPort(a4),a1
  8139.         move.l    MenuBackPen(a4),d0        ; Clear rastport
  8140.         DOLIB    SetRast
  8141.  
  8142.         move.l    MyRastPort(a4),a0        ; Blit
  8143.         moveq    #0,d0                ; to restore titlebar shape
  8144.         moveq    #0,d1
  8145.         move.l    -4(a5),a1
  8146.         move.l    sc_BarLayer(a1),a1
  8147.         move.l    lr_rp(a1),a1
  8148.         move.l    LeftEdge(a4),d2
  8149.         move.l    #1,d3
  8150.         moveq    #0,d5
  8151.         move.w    BitMapHeight(a4),d5
  8152.         move.l    BlitWidth(a4),d4
  8153.         move.l    #$c0,d6
  8154.         DOLIB    ClipBlit
  8155.  
  8156. .End        bsr    UnlockScreen
  8157.         unlk    a5
  8158. .Error        rts
  8159.  
  8160.  
  8161.  
  8162. **********************************************************************
  8163. *                  Load the specified Alarm sample                   *
  8164. **********************************************************************
  8165. InitAlarmSmp    tst.b    AlarmSample(a4)
  8166.         beq    .End
  8167.         tst.b    HadASample(a4)
  8168.         beq    .End
  8169.  
  8170.         SF    SampleLoaded(a4)
  8171.         SF    SampleLoaded(a4)
  8172.  
  8173.         move.l    #NOIFF_ERR,ErrorBack(a4)    ; Open IFF handle
  8174.         RELLIB    AllocIFF,_IFFParseBase
  8175.         move.l    d0,MyIFFHandle(a4)
  8176.         beq    .AlarmError1
  8177.  
  8178.         lea    AlSampleName(a4),a0        ; Open file
  8179.         move.l    a0,d1
  8180.         move.l    d1,BackErrArg(a4)
  8181.         move.l    #MODE_OLDFILE,d2
  8182.         RELLIB    Open,_DOSBase
  8183.         move.l    MyIFFHandle(a4),a0
  8184.         move.l    d0,iff_Stream(a0)
  8185.         beq    .DosAlarmError
  8186.  
  8187.         RELLIB    InitIFFasDOS,_IFFParseBase
  8188.  
  8189.         move.l    MyIFFHandle(a4),a0        ; Open for IFF read
  8190.         move.l    #IFFF_READ,d0
  8191.         DOLIB    OpenIFF
  8192.         tst.l    d0
  8193.         bne    .AlarmError
  8194.  
  8195.         move.l    MyIFFHandle(a4),a0        ; Search for these two
  8196.         move.l    #'8SVX',d0            ; chunks
  8197.         move.l    #'VHDR',d1
  8198.         DOLIB    PropChunk
  8199.         tst.l    d0
  8200.         bne    .AlarmError
  8201.  
  8202.         move.l    MyIFFHandle(a4),a0
  8203.         move.l    #'8SVX',d0
  8204.         move.l    #'BODY',d1
  8205.         DOLIB    StopChunk
  8206.         tst.l    d0
  8207.         bne    .AlarmError
  8208.  
  8209.         move.l    MyIFFHandle(a4),a0        ; Scan file
  8210.         move.l    #IFFPARSE_SCAN,d0
  8211.         DOLIB    ParseIFF
  8212.         tst.l    d0
  8213.         bne    .AlarmError
  8214.  
  8215.         move.l    MyIFFHandle(a4),a0        ; Check for VHDR
  8216.         move.l    #'8SVX',d0
  8217.         move.l    #'VHDR',d1
  8218.         DOLIB    FindProp
  8219.         tst.l    d0
  8220.         beq    .AlarmError
  8221.         move.l    d0,a0                ; Read out VHDR chunk
  8222.         move.l    spr_Data(a0),a0
  8223.         move.l    oneShotHiSamples(a0),AlarmHiSmp(a4)
  8224.         move.l    repeatHiSamples(a0),AlarmHiRep(a4)
  8225.         move.l    samplesPerHiCycle(a0),AlarmHiCyc(a4)
  8226.         move.w    samplesPerSec(a0),AlarmSmpSec(a4)
  8227.         move.b    ctOctave(a0),AlarmOctave(a4)
  8228.         move.l    Volume(a0),AlarmVolume(a4)
  8229.         move.l    AlarmHiSmp(a4),d0
  8230.         add.l    AlarmHiRep(a4),d0
  8231.         move.l    d0,AlarmSmpLen(a4)
  8232.  
  8233.         move.l    MyIFFHandle(a4),a0        ; Check for BODY
  8234.         DOLIB    CurrentChunk
  8235.         move.l    #MEMORY_ERR,ErrorBack(a4)    ; Try to get memory block
  8236.         move.l    d0,a3
  8237.         move.l    cn_Size(a3),d0
  8238.         move.l    #MEMF_CHIP,d1
  8239.         CALLSYS    AllocVec
  8240.         move.l    d0,AlarmSmpStart(a4)
  8241.         beq.s    .AlarmError1
  8242.  
  8243.         move.l    MyIFFHandle(a4),a0        ; Read sample
  8244.         move.l    d0,a1
  8245.         move.l    cn_Size(a3),d0
  8246.         RELLIB    ReadChunkBytes,_IFFParseBase
  8247.         cmp.l    cn_Size(a3),d0
  8248.         bne.s    .AlarmError
  8249.  
  8250.         move.l    #AUDIOPORT_ERR,ErrorBack(a4)    ; Get Message Port
  8251.         CALLSYS    CreateMsgPort
  8252.         move.l    d0,AlarmPort(a4)
  8253.         beq.s    .AlarmError1
  8254.  
  8255.         move.l    #AUDIOREQ_ERR,ErrorBack(a4)    ; Create Request
  8256.         move.l    AlarmPort(a4),a0
  8257.         clr.l    LN_NAME(a0)
  8258.         clr.b    LN_PRI(a0)
  8259.         move.l    #ioa_SIZEOF,d0
  8260.         CALLSYS    CreateIORequest
  8261.         move.l    d0,AlarmReq(a4)
  8262.         beq.s    .AlarmError1
  8263.  
  8264.         move.b    #1,SampleLoaded(a4)        ; Set flags
  8265.         move.b    #1,HadASample(a4)
  8266.         bra.s    .EndAlarm
  8267.  
  8268. .AlarmError    tst.l    d0
  8269.         beq.s    .EndAlarm
  8270.         neg.l    d0
  8271.         add.l    #400,d0
  8272.         move.l    d0,ErrorBack(a4)
  8273. .AlarmError1    bsr    DisplayError
  8274.         bra.s    .EndAlarm
  8275. .DosAlarmError    DOLIB    IoErr
  8276.         move.l    d0,ErrorBack(a4)
  8277.         bsr    DisplayError
  8278. .EndAlarm    tst.l    MyIFFHandle(a4)
  8279.         beq.s    .NoHandle
  8280.         move.l    MyIFFHandle(a4),a0
  8281.         RELLIB    CloseIFF,_IFFParseBase
  8282.         move.l    MyIFFHandle(a4),a0
  8283.         move.l    iff_Stream(a0),d1
  8284.         beq.s    .NoFile
  8285.         RELLIB    Close,_DOSBase
  8286. .NoFile        move.l    MyIFFHandle(a4),a0
  8287.         RELLIB    FreeIFF,_IFFParseBase
  8288. .NoHandle
  8289. .End        rts
  8290.  
  8291.  
  8292.  
  8293. **********************************************************************
  8294. *                     Remove Alarm sample stuff                      *
  8295. **********************************************************************
  8296. RemoveAlarmSmp    tst.l    AlarmSmpStart(a4)
  8297.         beq.s    .NoSample
  8298.         move.l    AlarmSmpStart(a4),a1
  8299.         CALLSYS    FreeVec
  8300. .NoSample    tst.l    AlarmPort(a4)
  8301.         beq.s    .NoPort
  8302.         move.l    AlarmPort(a4),a0
  8303.         CALLSYS    DeleteMsgPort
  8304. .NoPort        tst.l    AlarmReq(a4)
  8305.         beq.s    .NoReq
  8306.         move.l    AlarmReq(a4),a0
  8307.         CALLSYS    DeleteIORequest
  8308. .NoReq        clr.l    AlarmPort(a4)
  8309.         clr.l    AlarmReq(a4)
  8310.         clr.l    AlarmSmpStart(a4)
  8311.         clr.b    SampleLoaded(a4)
  8312.         rts
  8313.  
  8314.  
  8315.  
  8316. **********************************************************************
  8317. *                      Set drive noclick/click                       *
  8318. **********************************************************************
  8319. SetNoClick    movem.l    RegsAll,-(sp)
  8320.         lea    DriveRequests(a4),a3
  8321.         moveq    #3,d7
  8322. .Loop        move.l    (a3)+,d0
  8323.         beq.s    .GoOn
  8324.         move.l    d0,a0
  8325.         move.l    IO_UNIT(a0),a0
  8326.         tst.b    DriveNoClick(a4)
  8327.         beq.s    .ClickOFF
  8328.         or.b    #TDPF_NOCLICK,TDU_PUBFLAGS(a0)
  8329.         bra.s    .GoOn
  8330. .ClickOFF    and.b    #~TDPF_NOCLICK,TDU_PUBFLAGS(a0)
  8331. .GoOn        dbf    d7,.Loop
  8332.         movem.l    (sp)+,RegsAll
  8333.         rts
  8334.  
  8335.  
  8336.  
  8337.  
  8338.  
  8339.  
  8340. **********************************************************************
  8341. *           Routine for keeping up the correct online time           *
  8342. **********************************************************************
  8343. CheckOnline    tst.b    Online(a4)            ; Already online ?
  8344.         bne.s    StillOnline
  8345.  
  8346.         tst.b    BillRunning(a4)            ; Started bill manually ?
  8347.         beq.s    .NoStartBill
  8348.         ST    NoBillPDown(a4)
  8349.         bra.s    .StartBill
  8350.  
  8351. .NoStartBill    lea    $bfd000,a5
  8352.         btst    #CIAB_COMCD,ciapra(a5)
  8353.         bne    NotOnline
  8354.  
  8355. .StartBill    move.b    #1,Online(a4)            ; Reset flags
  8356.         clr.b    DontCheckTime(a4)
  8357.         clr.l    OnlineHour
  8358.         clr.l    OnlineMinute
  8359.         move.l    #5,OnlineSeconds        ; We already have a connect of about 3 secs
  8360.         move.l    #-5,NextUnit            ; Store for next unit calc
  8361.         move.l    #5,UnitsDone
  8362.         clr.l    TotalCost(a4)
  8363.         lea    AllTimeString(pc),a0        ; Copy current time and date
  8364.         lea    LogInTime(pc),a1
  8365.         bsr    StrCpy
  8366.         lea    AllDateString(pc),a0
  8367.         lea    LogInDate(pc),a1
  8368.         bsr    StrCpy
  8369.         lea    AllTimeString+6(pc),a0
  8370.         lea    CopyTime(pc),a1
  8371.         bsr    StrCpy
  8372.  
  8373. StillOnline    lea    $bfd000,a5
  8374.         btst    #CIAB_COMCD,ciapra(a5)        ; Still online ?
  8375.         beq    .GoOn
  8376.  
  8377.         tst.b    BillRunning(a4)            ; User selected manual count ?
  8378.         bne    .GoOn
  8379.  
  8380.         clr.b    Online(a4)            ; Nope....
  8381.         clr.b    DontCheckTime(a4)
  8382.  
  8383.         tst.b    LogCalls(a4)            ; Save log to file ?
  8384.         beq    .NoReenable
  8385.  
  8386.         cmp.l    #6,UnitsDone            ; Skip for extreme short calls (like 3 secs)
  8387.         ble    .NoReenable
  8388.  
  8389.         move.w    #'N',d0                ; Set char for either normal
  8390.         tst.b    CheapMode(a4)
  8391.         beq.s    .NoCheap
  8392.         move.w    #'C',d0                ; ... or cheap mode
  8393. .NoCheap    move.w    d0,LogEntryTariff
  8394.         clr.l    CostMajor            ; Calc total costs
  8395.         clr.l    CostMinor
  8396.         move.l    TotalCost(a4),d0
  8397. .CostLoop    cmp.l    #100,d0
  8398.         blt.s    .CostEnd
  8399.         sub.l    #100,d0
  8400.         addq.l    #1,CostMajor
  8401.         bra.s    .CostLoop
  8402. .CostEnd    move.l    d0,CostMinor
  8403.  
  8404.         link    a5,#-LOGENTRYSIZE        ; Get Buffer for log-entry
  8405.  
  8406.         move.l    TimeZone(a4),d0
  8407.         move.l    d0,LogTimeZone
  8408.  
  8409.         LOCLEA    LogEntryFormat,a0        ; Format log entry
  8410.         lea    LogEntryDat,a1
  8411.         lea    PutChProc(pc),a2
  8412.         lea    -LOGENTRYSIZE(a5),a3
  8413.         CALLSYS    RawDoFmt
  8414.  
  8415.         lea    LogFileName(a4),a0
  8416.         move.l    a0,d1                ; Open log file
  8417.         move.l    #MODE_READWRITE,d2
  8418.         RELLIB    Open,_DOSBase
  8419.         tst.l    d0
  8420.         beq.s    .NoLogWrite
  8421.         move.l    d0,d7
  8422.         move.l    d0,d1
  8423.         moveq    #0,d2
  8424.         move.l    #OFFSET_END,d3            ; Seek to end
  8425.         DOLIB    Seek
  8426.         lea    -LOGENTRYSIZE(a5),a0
  8427.         move.l    d7,d1
  8428.         move.l    a0,d2                ; Write new logentry
  8429.         DOLIB    FPuts
  8430.         move.l    d7,d1
  8431.         DOLIB    Close
  8432. .NoLogWrite    unlk    a5
  8433.  
  8434. .NoReenable    tst.b    BillPopUp(a4)
  8435.         beq.s    .EndLogOff
  8436.         tst.b    NoBillPDown(a4)
  8437.         bne.s    .EndLogOff
  8438.         bsr    CloseBillWin
  8439. .EndLogOff    clr.b    NoBillPDown(a4)
  8440.         clr.b    BillPopedUp(a4)
  8441.         bra    NotOnline
  8442.  
  8443. .GoOn        move.b    #1,Online(a4)            ; Yep, we`re online
  8444.  
  8445.         cmp.l    #6,UnitsDone            ; Open Bill window ?
  8446.         ble.s    .NoOpen
  8447.  
  8448.         tst.b    BillPopUp(a4)
  8449.         beq.s    .NoOpen
  8450.         tst.b    BillPopedUp(a4)
  8451.         bne.s    .NoOpen
  8452.         tst.l    BillHandle(a4)
  8453.         beq.s    .DoOpen
  8454.         move.b    #1,NoBillPDown(a4)
  8455. .DoOpen        move.b    #1,BillPopedUp(a4)
  8456.         bsr    OpenBillWin
  8457.  
  8458. .NoOpen        link    a5,#-4
  8459.         lea    -4(a5),a3
  8460.         lea    AllTimeString+6(pc),a0        ; Get current seconds
  8461.         move.l    a0,d1
  8462.         move.l    a3,d2
  8463.         RELLIB    StrToLong,_DOSBase
  8464.         move.l    d1,d7                ; Convert to long
  8465.         lea    CopyTime(pc),a0            ; Get last seconds
  8466.         move.l    a0,d1
  8467.         move.l    a3,d2
  8468.         DOLIB    StrToLong            ; Convert to long
  8469.         unlk    a5
  8470.         moveq    #0,d5
  8471. .GetValue    cmp.l    d1,d7                ; Got seconds elapsed ?
  8472.         beq.s    .GotValue            ; Yep -> go on
  8473.         addq.l    #1,d5                ; One more second done
  8474.         addq.l    #1,d1
  8475.         cmp.l    #60,d1                ; Over 60 boundary ?
  8476.         bne.s    .GetValue
  8477.         moveq    #0,d1                ; Restart from scratch
  8478.         bra.s    .GetValue
  8479. .GotValue    add.l    d5,OnlineSeconds        ; Remake online time
  8480.         cmp.l    #60,OnlineSeconds        ; One minute done ?
  8481.         blt.s    .End                ; Nope -> go on
  8482.         sub.l    #60,OnlineSeconds
  8483.         addq.l    #1,OnlineMinute
  8484.         cmp.l    #60,OnlineMinute        ; One hour online ? GOSH
  8485.         bne.s    .End                ; Nope -> go on
  8486.         clr.l    OnlineMinute
  8487.         addq.l    #1,OnlineHour
  8488.  
  8489. .End        lea    AllTimeString+6(pc),a0        ; Copy current time
  8490.         lea    CopyTime(pc),a1
  8491.         bsr    StrCpy
  8492.  
  8493.         sub.l    d5,NextUnit
  8494.         add.l    d5,UnitsDone
  8495. NotOnline
  8496. **********************************************************************
  8497. *                  Remake texts within Bill window                   *
  8498. **********************************************************************
  8499. RemakeCosts    tst.b    DontCheckTime(a4)        ; Check for time ?
  8500.         bne    .NoRemake
  8501.         lea    MyDateTime(a4),a0        ; Get current datestamp
  8502.         move.l    ds_Days(a0),d0            ; Calc daynumber
  8503.         divu    #7,d0
  8504.         clr.w    d0
  8505.         swap    d0
  8506.         lea    Sunday(a4),a0
  8507.         tst.b    0(a0,d0.w)            ; Bit for "always cheap" set ?
  8508.         beq.s    .NormalDay            ; Nope -> normal day
  8509.         link    a5,#-12
  8510.         moveq    #1,d3                ; Set flag and treat as cheap
  8511.         bra    .Done
  8512.  
  8513. .NormalDay    link    a5,#-12
  8514.         lea    MyDateTime(a4),a0        ; Get datestamp
  8515.         move.l    ds_Minute(a0),d0        ; Get current minute
  8516.         divu    #60,d0
  8517.         moveq    #0,d1
  8518.         move.w    d0,d1                ; D1 = minutes
  8519.         clr.w    d0
  8520.         swap    d0                ; D0 = hours
  8521.         move.l    d1,-8(a5)
  8522.         move.l    d0,-4(a5)
  8523.  
  8524.         move.l    -8(a5),d2            ; Calc number of ten minutes done
  8525.         mulu    #6,d2
  8526.         and.l    #$0000ffff,d2
  8527.         move.l    -4(a5),d3
  8528.         divu    #10,d3
  8529.         and.l    #$0000ffff,d3
  8530.         addq.l    #1,d3
  8531.         add.l    d3,d2                ; d2 = Current time
  8532.  
  8533.         move.l    CheapStart(a4),d0        ; Check for normal/cheap time
  8534.         move.l    CheapStop(a4),d1
  8535.  
  8536.         cmp.l    d0,d2
  8537.         blt.s    .NoCheap1
  8538.         cmp.l    d1,d2
  8539.         bgt.s    .NoCheap1
  8540.         moveq    #1,d3
  8541.         bra.s    .Done
  8542. .NoCheap1    cmp.l    d1,d2
  8543.         blt.s    .NoCheap2
  8544.         cmp.l    d0,d2
  8545.         bgt.s    .NoCheap2
  8546.         moveq    #0,d3
  8547.         bra.s    .Done
  8548. .NoCheap2    cmp.l    d0,d2
  8549.         blt.s    .NoCheap3
  8550.         cmp.l    d1,d2
  8551.         blt.s    .NoCheap3
  8552.         cmp.l    d0,d1
  8553.         bgt.s    .NoCheap4
  8554.         moveq    #1,d3
  8555.         bra.s    .Done
  8556. .NoCheap4    moveq    #0,d3
  8557.         bra.s    .Done
  8558. .NoCheap3    cmp.l    d0,d2
  8559.         bgt.s    .Done
  8560.         cmp.l    d1,d2
  8561.         bgt.s    .Done
  8562.         cmp.l    d0,d1
  8563.         bgt.s    .NoCheap6
  8564.         moveq    #1,d3
  8565.         bra.s    .Done
  8566. .NoCheap6    moveq    #0,d3
  8567. .Done        cmp.b    CheapMode(a4),d3
  8568.         beq.s    .TimeDone
  8569.         move.b    d3,CheapMode(a4)
  8570.         move.l    #GD_BillCheap,d0
  8571.         move.l    d3,d1
  8572.         lea    BillGads(a4),a0
  8573.         move.l    BillHandle(a4),a1
  8574.         RELLIB    SetMXGad,_KCXBase
  8575.         clr.b    DoRemakeCosts(a4)
  8576. .TimeDone    unlk    a5
  8577.  
  8578. .NoRemake    tst.b    Online(a4)            ; Are we online ?
  8579.         beq.s    .NotOnline
  8580.         tst.l    NextUnit            ; Next unit
  8581.         bgt.s    .NotOnline            ; Nope...
  8582.         move.l    NextUnit,d1
  8583.         neg.l    d1
  8584.         move.l    TimeZone(a4),d0            ; Get timezone
  8585.         lsl.l    #3,d0
  8586.         lea    CostUnit1(a4),a0
  8587.         tst.b    CheapMode(a4)
  8588.         beq.s    .Normal
  8589.         move.l    cu_Cheap(a0,d0),d0        ; Get costs for cheap mode
  8590.         bra.s    .GoOn
  8591. .Normal        move.l    cu_Normal(a0,d0),d0        ; or for normal mode
  8592.  
  8593. .GoOn        move.l    d0,d2
  8594.         sub.l    d1,d0                ; Skip "over" seconds
  8595.         move.l    d0,NextUnit            ; Store for next unit calc
  8596.  
  8597.         tst.l    d2
  8598.         bgt.s    .DIV0
  8599.         move.l    #23,TotalCost(a4)
  8600.         bra.s    .NoNewCost1
  8601. .DIV0        move.l    CostUnit(a4),d0            ; Remake costs
  8602.         add.l    d0,TotalCost(a4)
  8603. .NoNewCost1    bsr    DisplayCost
  8604.  
  8605. .NotOnline    tst.b    DoRemakeCosts(a4)
  8606.         beq.s    .NoCostRemake
  8607.         clr.b    DoRemakeCosts(a4)
  8608.         move.l    TimeZone(a4),d0            ; Changed time/cheap mode ?
  8609.         lea    CostUnit1(a4),a0
  8610.         lsl.l    #3,d0
  8611.         tst.b    CheapMode(a4)
  8612.         beq.s    .RemNormal
  8613.         move.l    cu_Cheap(a0,d0),d0        ; Get new time
  8614.         bra.s    .GoOnRemake
  8615. .RemNormal    move.l    cu_Normal(a0,d0),d0
  8616. .GoOnRemake    tst.l    d0                ; Check for infinite costs
  8617.         bgt.s    .DIV1
  8618.         move.l    CostUnit(a4),d2
  8619.         bra.s    .NoInitial2
  8620. .DIV1        move.l    UnitsDone(pc),d2
  8621.         divu    d0,d2
  8622.         and.l    #$0000ffff,d2
  8623.         tst.b    Online(a4)
  8624.         beq.s    .NoInitial
  8625.         tst.l    TotalCost(a4)
  8626.         beq.s    .NoInitial
  8627.         addq.l    #1,d2                ; D2 = Number of units done for new time
  8628. .NoInitial    move.l    CostUnit(a4),d3
  8629.         mulu    d3,d2                ; Get new costs for new time
  8630. .NoInitial2    move.l    d2,TotalCost(a4)        ; Store costs
  8631.         tst.l    d0                ; Infinite costs
  8632.         bgt.s    .DIV2
  8633.         move.l    #1,NextUnit            ; Store calc for next unit
  8634.         bra.s    .NoDIV2
  8635. .DIV2        move.l    UnitsDone(pc),d2        ; Units done
  8636.         divu    d0,d2                ; Calc overlap for next unit
  8637.         clr.w    d2
  8638.         swap    d2
  8639.         sub.l    d2,d0                ; D0 = Event for next unit
  8640.         bge.s    .NoSubUnit            ; On negative value
  8641.         neg.l    d0                ; make it positive
  8642. .NoSubUnit    move.l    d0,NextUnit
  8643. .NoDIV2        bsr    DisplayCost
  8644. .NoCostRemake    clr.l    CostMajor
  8645.         clr.l    CostMinor
  8646.         move.l    TimeZone(a4),d0            ; Calc total costs
  8647.         lsl.l    #3,d0
  8648.         lea    CostUnit1(a4),a0
  8649.         lea    0(a0,d0),a0
  8650.         tst.b    CheapMode(a4)
  8651.         beq.s    .StillNormal
  8652.         move.l    cu_Cheap(a0),d1            ; either for cheap mode
  8653.         bra.s    .StillCheap
  8654. .StillNormal    move.l    cu_Normal(a0),d1        ; or for normal mode
  8655. .StillCheap    tst.l    d1                ; Check for infinite costs
  8656.         bgt.s    .DIV3
  8657.         move.l    CostUnit(a4),d0
  8658.         bra.s    .TotLoop
  8659. .DIV3        move.l    #3600,d0
  8660.         divu    d1,d0
  8661.         and.l    #$0000ffff,d0            ; d0 = Number of units/hour
  8662.         move.l    CostUnit(a4),d1
  8663.         mulu    d1,d0                ; d0 = costs/hour
  8664. .TotLoop    cmp.l    #100,d0                ; convert value
  8665.         blt.s    .EndLoop
  8666.         sub.l    #100,d0
  8667.         addq.l    #1,CostMajor
  8668.         bra.s    .TotLoop
  8669. .EndLoop    move.l    d0,CostMinor
  8670.  
  8671.         lea    FormLongSStr,a0            ; Create Onlinetime
  8672.         lea    OnlineHour,a1
  8673.         lea    PutChProc(pc),a2
  8674.         lea    OnlineString(pc),a3
  8675.         CALLSYS    RawDoFmt
  8676.  
  8677.         tst.l    BillHandle(a4)
  8678.         beq    NoCostCalc
  8679.         tst.b    Zipped(a4)
  8680.         bne.s    .ZippedTitle
  8681.  
  8682.         LOCLEA    PerHourStr,a0
  8683.         lea    PerHourBuff(a4),a1
  8684.         bsr    StrCpy
  8685.         subq.l    #1,a1
  8686.         move.l    a1,a3
  8687.         lea    PerHourForm,a0            ; Convert values to string
  8688.         lea    CostMajor,a1
  8689.         lea    PutChProc(pc),a2
  8690.         DOLIB    RawDoFmt
  8691.  
  8692.         move.l    #GD_BillTime,d0            ; Set text gadgets
  8693.         lea    BillGads(a4),a0
  8694.         move.l    BillHandle(a4),a1
  8695.         lea    AllTimeString(pc),a2
  8696.         RELLIB    SetTextGad,_KCXBase
  8697.  
  8698.         move.l    #GD_BillOnline,d0
  8699.         lea    OnlineString(pc),a2
  8700.         DOLIB    SetTextGad
  8701.  
  8702.         move.l    #GD_BillCost,d0
  8703.         lea    CostString(pc),a2
  8704.         DOLIB    SetTextGad
  8705.  
  8706.         move.l    #GD_BillHour,d0
  8707.         lea    PerHourBuff(a4),a2
  8708.         DOLIB    SetTextGad
  8709.         bra    NoCostCalc
  8710.  
  8711. .ZippedTitle    lea    OnlineString(pc),a0        ; IF window is zipped, create
  8712.         lea    FinalString2(a4),a1        ; appropriate title
  8713.         bsr    StrCpy
  8714.         lea    CostString(pc),a0
  8715.         lea    FinalString2(a4),a1
  8716.         bsr    StrCat
  8717.  
  8718.         link    a5,#-6
  8719.         lea    -6(a5),a0
  8720.         move.b    #',',(a0)
  8721.         move.l    TimeZone(a4),d0
  8722.         add.b    #'1',d0
  8723.         move.b    d0,1(a0)
  8724.         tst.b    CheapMode(a4)
  8725.         beq.s    .NoCheap
  8726.         LOCLEA    CheapChar,a1
  8727.         bra.s    .EndZone
  8728. .NoCheap    LOCLEA    NormChar,a1
  8729. .EndZone    move.b    (a1),2(a0)
  8730.         tst.b    LogCalls(a4)
  8731.         beq.s    .NoLog
  8732.         move.l    a0,-(sp)
  8733.         LOCLEA    LogCallText,a0
  8734.         bsr    LocalizeGadKey
  8735.         move.l    (sp)+,a0
  8736.         move.b    d1,3(a0)
  8737.         bra.s    .EndLog
  8738. .NoLog        move.b    #' ',3(a0)
  8739. .EndLog        clr.b    4(a0)
  8740.         lea    FinalString2(a4),a1
  8741.         bsr    StrCat
  8742.         unlk    a5
  8743.  
  8744.         move.l    BillHandle(a4),a0        ; Display / OnlineString
  8745.         lea    FinalString2(a4),a1
  8746.         suba.l    a2,a2
  8747.         subq.w    #1,a2
  8748.         RELLIB    SetWindowTitles,_IntuitionBase
  8749. NoCostCalc    rts
  8750.  
  8751.  
  8752.  
  8753. **********************************************************************
  8754. *                Display new costs of telephone call                 *
  8755. **********************************************************************
  8756. DisplayCost    move.l    TotalCost(a4),d0
  8757.         clr.l    CostMajor
  8758.         clr.l    CostMinor
  8759.  
  8760. .Loop        cmp.l    #100,d0                ; Calc costs
  8761.         blt.s    .LoopEnd
  8762.         sub.l    #100,d0
  8763.         addq.l    #1,CostMajor
  8764.         bra.s    .Loop
  8765. .LoopEnd    move.l    d0,CostMinor
  8766.  
  8767.         lea    CostFormString,a0        ; Convert values
  8768.         lea    CostMajor,a1
  8769.         lea    PutChProc(pc),a2
  8770.         lea    CostString,a3
  8771.         CALLSYS    RawDoFmt
  8772.         rts
  8773.  
  8774.  
  8775. **********************************************************************
  8776. *                      Check if we`re to alarm                       *
  8777. **********************************************************************
  8778. CheckForAlarm    tst.b    DoAlarm(a4)            ; Are we to alarm ?
  8779.         beq.s    NoAlarm
  8780.  
  8781.         tst.b    EveryHour(a4)
  8782.         beq.s    .NoEveryHour
  8783.         link    a5,#-12
  8784.         lea    AllTimeString(pc),a0
  8785.         lea    -4(a5),a1
  8786.         move.b    (a0)+,(a1)
  8787.         move.b    (a0)+,1(a1)
  8788.         clr.b    2(a1)
  8789.         clr.b    3(a1)
  8790.         move.l    a1,d1
  8791.         lea    -12(a5),a0
  8792.         move.l    a0,d2
  8793.         RELLIB    StrToLong,_DOSBase
  8794.         move.l    -12(a5),d0
  8795.         unlk    a5
  8796.         tst.l    ThisHour(a4)
  8797.         bge.s    .GoOn
  8798.         move.l    d0,ThisHour(a4)
  8799.         bra.s    .NoEveryHour
  8800. .GoOn        move.l    ThisHour(a4),d1
  8801.         move.l    d0,ThisHour(a4)
  8802.         cmp.l    d0,d1
  8803.         bne.s    .DoAlarm
  8804. .NoEveryHour    lea    AllTimeString(pc),a0
  8805.         bsr.s    GetAlarmCode
  8806.         cmp.l    AlarmTime(a4),d0
  8807.         bne.s    NoAlarm
  8808. .DoAlarm    lea    AllTimeString(pc),a0
  8809.         cmp.b    #'0',6(a0)
  8810.         bne.s    NoAlarm
  8811.         cmp.b    #'0',7(a0)
  8812.         bne.s    NoAlarm
  8813.         move.l    BackTask(a4),a1            ; Signal mother to alarm
  8814.         move.l    AlarmSigFlag(a4),d0
  8815.         CALLSYS    Signal
  8816. NoAlarm        rts
  8817.  
  8818.  
  8819. **********************************************************************
  8820. *                         Get number of time                         *
  8821. **********************************************************************
  8822. GetAlarmCode    link    a5,#-(8+LEN_DATSTRING)
  8823.         lea    -(8+LEN_DATSTRING)(a5),a1
  8824.         bsr    StrCpy
  8825.         lea    -(8+LEN_DATSTRING)(a5),a3
  8826.         clr.b    2(a3)
  8827.         clr.b    5(a3)
  8828.         move.l    a3,d1
  8829.         lea    -4(a5),a0
  8830.         move.l    a0,d2
  8831.         RELLIB    StrToLong,_DOSBase
  8832.         tst.l    d0
  8833.         ble.s    .Error
  8834.         move.l    a3,d1
  8835.         addq.l    #3,d1
  8836.         lea    -8(a5),a0
  8837.         move.l    a0,d2
  8838.         RELLIB    StrToLong,_DOSBase
  8839.         tst.l    d0
  8840.         ble.s    .Error
  8841.         move.l    -4(a5),d0
  8842.         mulu    #60,d0
  8843.         add.l    -8(a5),d0
  8844.         unlk    a5
  8845.         rts
  8846. .Error        moveq    #-1,d0
  8847.         unlk    a5
  8848.         rts
  8849.  
  8850.  
  8851.  
  8852. **********************************************************************
  8853. *                        Do the full dragging                        *
  8854. **********************************************************************
  8855. DoDragging    movem.l    RegsAll,-(sp)
  8856.  
  8857.         link    a5,#-38
  8858.         RELLIB    FindWindow,_KCXBase        ; Get window underneith mouse
  8859.         tst.l    d0
  8860.         beq    .NoDrag
  8861.         move.l    d0,a0
  8862.         tst.l    lr_Window(a0)
  8863.         beq    .NoDrag
  8864.         move.l    lr_Window(a0),a0        ; Window equipped with a dragbar ?
  8865.         move.l    wd_Flags(a0),d0
  8866.         and.l    #WFLG_DRAGBAR,d0
  8867.         beq    .NoDrag
  8868.         move.l    a0,-4(a5)            ; Store pointer to window
  8869.         move.l    wd_WScreen(a0),-8(a5)        ; Store Pointer to screen
  8870.  
  8871.         move.l    -8(a5),a0            ; Set DrawMode
  8872.         lea    sc_RastPort(a0),a1
  8873.         move.l    a1,-12(a5)
  8874.         moveq    #0,d0                ; Store old Drawmode
  8875.         move.b    rp_DrawMode(a1),d0
  8876.         move.w    d0,-14(a5)
  8877.         move.l    #RP_COMPLEMENT,d0
  8878.         RELLIB    SetDrMd,_GfxBase
  8879.  
  8880.         move.l    -4(a5),a0            ; Get Window dimensions
  8881.         move.w    wd_LeftEdge(a0),-16(a5)
  8882.         move.w    wd_TopEdge(a0),-18(a5)
  8883.         move.w    wd_Width(a0),-20(a5)
  8884.         move.w    wd_Height(a0),-22(a5)
  8885.         subq.w    #1,-20(a5)
  8886.         subq.w    #1,-22(a5)
  8887.  
  8888.         move.l    -8(a5),a0            ; Get Screen dimensions
  8889.         move.w    sc_Width(a0),d0
  8890.         sub.w    -20(a5),d0
  8891.         subq.w    #1,d0
  8892.         move.w    d0,-24(a5)
  8893.         move.w    sc_Height(a0),d0
  8894.         sub.w    -22(a5),d0
  8895.         subq.w    #1,d0
  8896.         move.w    d0,-26(a5)
  8897.  
  8898.         move.l    -8(a5),a1            ; Get ViewModes to check how to move
  8899.         bsr    GetCoords            ; Get current mouse coordinates
  8900.         move.w    d2,-28(a5)
  8901.         move.w    d3,-30(a5)
  8902.         move.w    d2,-32(a5)            ; Double position
  8903.         move.w    d3,-34(a5)
  8904.         sub.w    -16(a5),d2
  8905.         sub.w    -18(a5),d3
  8906.         move.w    d2,-16(a5)
  8907.         move.w    d3,-18(a5)
  8908.  
  8909.         move.b    #1,ImDragging(a4)
  8910.         bsr    DrawWndRec            ; Draw first rectangle
  8911. .DragLoop    move.l    #SIGLBUTTON|SIGMOUSE,d0
  8912.         CALLSYS    Wait
  8913.         and.l    #SIGLBUTTON,d0
  8914.         bne.s    .DragLoopEnd
  8915.         move.l    -8(a5),a1            ; Get ViewModes to check how to move
  8916.         bsr    GetCoords            ; Get mouse coordinates
  8917.         cmp.w    -28(a5),d2            ; Position changed ?
  8918.         bne.s    .NewPos
  8919.         cmp.w    -30(a5),d3
  8920.         beq.s    .DragLoop
  8921. .NewPos        bsr.s    DrawWndRec            ; Clear last rec
  8922.         move.w    d2,-28(a5)            ; Store new positions
  8923.         move.w    d3,-30(a5)
  8924.         bsr.s    DrawWndRec            ; Draw new rec
  8925.         bra.s    .DragLoop
  8926. .DragLoopEnd    bsr.s    DrawWndRec
  8927.         clr.b    ImDragging(a4)
  8928.  
  8929. .EndDrag    move.l    -8(a5),a0            ; Reset old drawmode
  8930.         lea    sc_RastPort(a0),a1
  8931.         move.w    -14(a5),d0
  8932.         RELLIB    SetDrMd,_GfxBase
  8933.  
  8934.         move.w    -28(a5),d0            ; Mouse position changed ?
  8935.         move.w    -30(a5),d1
  8936.         cmp.w    -32(a5),d0
  8937.         bne.s    .NewWinPos
  8938.         cmp.w    -34(a5),d1
  8939.         bne.s    .NewWinPos
  8940. .NewWinPos    move.l    -4(a5),a0            ; Yep
  8941.         bsr    TestPosition            ; Get new left/top edge
  8942.         move.w    d4,d0
  8943.         move.w    d5,d1
  8944.         move.w    wd_Width(a0),d2            ; Get width
  8945.         move.w    wd_Height(a0),d3
  8946.         RELLIB    ChangeWindowBox,_IntuitionBase    ; Move window
  8947. .NoDrag        unlk    a5
  8948.         movem.l    (sp)+,RegsAll
  8949.         rts
  8950.  
  8951.  
  8952.  
  8953. **********************************************************************
  8954. *                    Draw the window`s rectangle                     *
  8955. **********************************************************************
  8956. DrawWndRec    move.l    -8(a5),a0            ; Lock layers
  8957.         lea    sc_LayerInfo(a0),a0
  8958.         RELLIB    LockLayers,_LayersBase
  8959.         bsr.s    TestPosition
  8960.         move.l    -12(a5),a1
  8961.         move.w    d4,d0
  8962.         move.w    d5,d1
  8963.         RELLIB    Move,_GfxBase
  8964.  
  8965.         move.w    -20(a5),d0
  8966.         moveq    #0,d1
  8967.         bsr.s    .DoDraw
  8968.  
  8969.         move.w    -20(a5),d0
  8970.         move.w    -22(a5),d1
  8971.         bsr.s    .DoDraw
  8972.  
  8973.         moveq    #0,d0
  8974.         move.w    -22(a5),d1
  8975.         bsr.s    .DoDraw
  8976.  
  8977.         moveq    #0,d0
  8978.         moveq    #0,d1
  8979.         bsr.s    .DoDraw
  8980.  
  8981.         move.l    -8(a5),a0            ; Unlock layers again
  8982.         lea    sc_LayerInfo(a0),a0
  8983.         RELLIB    UnlockLayers,_LayersBase
  8984.         rts
  8985.  
  8986. .DoDraw        move.l    -12(a5),a1
  8987.         add.w    d4,d0
  8988.         add.w    d5,d1
  8989.         jmp    _LVODraw(a6)
  8990.  
  8991.  
  8992. **********************************************************************
  8993. *                      Get correct coordinates                       *
  8994. **********************************************************************
  8995. GetCoords    move.l    a1,-(sp)
  8996.         moveq    #0,d0
  8997.         RELLIB    LockIBase,_IntuitionBase
  8998.         move.l    d0,d5
  8999.         move.l    (sp)+,a1
  9000.         move.l    ib_ActiveScreen(a6),a0
  9001.         moveq    #0,d2
  9002.         moveq    #0,d3
  9003.         move.w    sc_MouseX(a0),d2
  9004.         move.w    sc_MouseY(a0),d3
  9005.         movem.l    RegsAll,-(sp)
  9006.         move.l    d5,a0
  9007.         DOLIB    UnlockIBase
  9008.         movem.l    (sp)+,RegsAll
  9009.         rts
  9010.  
  9011.  
  9012. **********************************************************************
  9013. *                     Test the current positions                     *
  9014. **********************************************************************
  9015. TestPosition    move.w    -28(a5),d4
  9016.         sub.w    -16(a5),d4
  9017.         bge.s    .XBig
  9018.         moveq    #0,d4
  9019.         bra.s    .CheckY
  9020. .XBig        cmp.w    -24(a5),d4
  9021.         ble.s    .CheckY
  9022.         move.w    -24(a5),d4
  9023. .CheckY        move.w    -30(a5),d5
  9024.         sub.w    -18(a5),d5
  9025.         bge.s    .YBig
  9026.         moveq    #0,d5
  9027.         bra.s    .End
  9028. .YBig        cmp.w    -26(a5),d5
  9029.         ble.s    .End
  9030.         move.w    -26(a5),d5
  9031. .End        rts
  9032.  
  9033.  
  9034.  
  9035. **********************************************************************
  9036. *          This is the routine for handleing ARexx command           *
  9037. **********************************************************************
  9038. GD_WindowAct                           EQU    0
  9039. GD_SunMouse                            EQU    1
  9040. GD_WriteEnv                            EQU    0
  9041. GD_ScrTime                             EQU    1
  9042. GD_MouseTime                           EQU    2
  9043. GD_CycleOn                             EQU    0
  9044. GD_PopUpBill                           EQU    9
  9045. GD_ESCClose                            EQU    0
  9046. GD_MapUmlauts                          EQU    2
  9047. GD_FKeyAct                             EQU    11
  9048. GD_MenuWrap                            EQU    6
  9049. HandleARexx    move.l    ARexxPort(a4),a0        ; Get ARexx msg
  9050.         CALLSYS    GetMsg
  9051.         move.l    d0,MyARexxMsg(a4)
  9052.         beq    AllARexxDone
  9053.         move.l    d0,a0
  9054.  
  9055.         move.l    ACTION(a0),d0            ; Get action to be taken
  9056.         move.l    d0,ARexxAction(a4)
  9057.         move.l    ARG0(a0),ARexxCommand(a4)
  9058.  
  9059.         move.l    #RC_OK,AResult1(a4)
  9060.         clr.l    AResult2(a4)
  9061.  
  9062.         and.l    #RXCOMM,d0            ; Is it a command ?
  9063.         beq    ARexxCommDone
  9064.  
  9065.         lea    ActivateStr(pc),a1        ; Window activation ?
  9066.         bsr    CheckARexxComm
  9067.         bne.s    ANoActivate
  9068.  
  9069.         bsr    CheckABool
  9070.         tst.l    d0
  9071.         blt    ACommFail
  9072.         move.b    d0,DoActivate(a4)
  9073.         CALLSYS    Forbid
  9074.         move.l    #GD_WindowAct,d1
  9075.         lea    MouseGads(a4),a0
  9076.         move.l    MouseHandle(a4),a1
  9077.         RELLIB    SetCheckBox,_KCXBase
  9078.         CALLSYS    Permit
  9079.         bra    ARexxCommDone
  9080.  
  9081. ANoActivate    lea    MouseStr(pc),a1            ; Sunmouse ?
  9082.         bsr    CheckARexxComm
  9083.         bne.s    ANoSunMouse
  9084.  
  9085.         bsr    CheckABool
  9086.         tst.l    d0
  9087.         blt    ACommFail
  9088.         move.b    d0,SunMouse(a4)
  9089.         CALLSYS    Forbid
  9090.         move.l    #GD_SunMouse,d1
  9091.         lea    MouseGads(a4),a0
  9092.         move.l    MouseHandle(a4),a1
  9093.         RELLIB    SetCheckBox,_KCXBase
  9094.         CALLSYS    Permit
  9095.         bra    ARexxCommDone
  9096.  
  9097. ANoSunMouse    lea    MenuWrapStr(pc),a1        ; On/Off MenuWrap ?
  9098.         bsr    CheckARexxComm
  9099.         bne.s    ANoMenuWrap
  9100.  
  9101.         bsr    CheckABool
  9102.         tst.l    d0
  9103.         blt    ACommFail
  9104.         move.b    d0,MenuWrap(a4)
  9105.         CALLSYS    Forbid
  9106.         move.l    #GD_MenuWrap,d1
  9107.         lea    SetGads(a4),a0
  9108.         move.l    SetHandle(a4),a1
  9109.         RELLIB    SetCheckBox,_KCXBase
  9110.         CALLSYS    Permit
  9111.         bra    ARexxCommDone
  9112.  
  9113. ANoMenuWrap    lea    PageNumStr(pc),a1        ; New pagenumber ?
  9114.         bsr    CheckARexxComm
  9115.         bne.s    ANoPageNum
  9116.  
  9117.         move.l    PageNum(a4),d7
  9118.         move.l    a0,d1
  9119.         lea    PageNum(a4),a0
  9120.         move.l    a0,d2
  9121.         RELLIB    StrToLong,_DOSBase
  9122.         tst.l    d0
  9123.         ble.s    .Error
  9124.         tst.l    PageNum(a4)
  9125.         blt.s    .Error
  9126.         cmp.l    #MAXPAGES,PageNum(a4)
  9127.         blt.s    .End
  9128. .Error        clr.l    PageNum(a4)
  9129. .End        move.l    PageNum(a4),d0
  9130.         move.l    d0,OldPageNum(a4)
  9131.         CALLSYS    Forbid
  9132.         bsr    ClearTitleBar
  9133.         bsr    SigTime
  9134.         CALLSYS    Permit
  9135.         bra    ARexxCommDone
  9136.  
  9137. ANoPageNum    lea    SetEnvStr(pc),a1        ; Write env-vars?
  9138.         bsr    CheckARexxComm
  9139.         bne.s    ANoSetEnv
  9140.  
  9141.         bsr    CheckABool            ; Bool flag ???
  9142.         tst.l    d0
  9143.         blt    ACommFail
  9144.         move.b    d0,SetEnv(a4)
  9145.         tst.b    SetEnv(a4)
  9146.         bne.s    .NoDel
  9147.         bsr    DeleteEnvs            ; Delete vars if setenv is off
  9148. .NoDel        CALLSYS    Forbid
  9149.         bsr    SigTime                ; Set the time
  9150.         move.b    SetEnv(a4),d0
  9151.         move.l    #GD_WriteEnv,d1
  9152.         lea    SetGads(a4),a0
  9153.         move.l    SetHandle(a4),a1
  9154.         RELLIB    SetCheckBox,_KCXBase
  9155.         CALLSYS    Permit
  9156.         bra    ARexxCommDone
  9157.  
  9158. ANoSetEnv    lea    ScreenTStr(pc),a1        ; New screen time ?
  9159.         bsr    CheckARexxComm
  9160.         bne.s    ANoScreenTime
  9161.         move.l    ScreenTime(a4),d7
  9162.         move.l    ARexxBuffer(a4),a1
  9163.         bsr    StrCpy
  9164.         move.l    ARexxBuffer(a4),d1
  9165.         lea    ScreenTime(a4),a0
  9166.         move.l    a0,d2
  9167.         RELLIB    StrToLong,_DOSBase        ; Get new time
  9168.         tst.l    ScreenTime(a4)            ; negative ?
  9169.         blt.s    .Error                ; disable blank
  9170.         tst.l    d0
  9171.         bge.s    .GoOn
  9172. .Error        move.l    d7,ScreenTime(a4)
  9173. .GoOn        move.b    #1,TimeReset(a4)
  9174.         CALLSYS    Forbid
  9175.         move.l    #GD_ScrTime,d0
  9176.         move.l    ScreenTime(a4),d1
  9177.         lea    BlankGads(a4),a0
  9178.         move.l    BlankHandle(a4),a1
  9179.         RELLIB    SetCheckBox,_KCXBase
  9180.         CALLSYS    Permit
  9181.         bra    ARexxCommDone
  9182.  
  9183. ANoScreenTime    lea    MouseTStr(pc),a1        ; New mouse time ?
  9184.         bsr    CheckARexxComm
  9185.         bne.s    ANoMouseTime
  9186.         move.l    MouseTime(a4),d7
  9187.         move.l    ARexxBuffer(a4),a1
  9188.         bsr    StrCpy
  9189.         move.l    ARexxBuffer(a4),d1
  9190.         lea    MouseTime(a4),a0
  9191.         move.l    a0,d2
  9192.         RELLIB    StrToLong,_DOSBase        ; Get new time
  9193.         tst.l    MouseTime(a4)            ; Negative -> disable blank
  9194.         blt.s    .Error
  9195.         tst.l    d0
  9196.         bge.s    .GoOn
  9197. .Error        move.l    d7,MouseTime(a4)
  9198. .GoOn        move.b    #1,TimeReset(a4)
  9199.         CALLSYS    Forbid
  9200.         move.l    #GD_MouseTime,d0
  9201.         move.l    MouseTime(a4),d1
  9202.         lea    BlankGads(a4),a0
  9203.         move.l    BlankHandle(a4),a1
  9204.         RELLIB    SetCheckBox,_KCXBase
  9205.         CALLSYS    Permit
  9206.         bra    ARexxCommDone
  9207.  
  9208. ANoMouseTime    lea    CycleWStr(pc),a1        ; Cycling enabled ?
  9209.         bsr    CheckARexxComm
  9210.         bne.s    ANoCycleWin
  9211.  
  9212.         bsr    CheckABool
  9213.         tst.l    d0
  9214.         blt    ACommFail
  9215.         move.b    d0,CycleWin(a4)
  9216.         CALLSYS    Forbid
  9217.         move.l    #GD_CycleOn,d1
  9218.         lea    CycleGads(a4),a0
  9219.         move.l    CycleHandle(a4),a1
  9220.         RELLIB    SetCheckBox,_KCXBase
  9221.         CALLSYS    Permit
  9222.         bra    ARexxCommDone
  9223.  
  9224. ANoCycleWin    lea    LogCallStr(pc),a1        ; Log calls ??
  9225.         bsr    CheckARexxComm
  9226.         bne.s    ANoLogCalls
  9227.  
  9228.         bsr    CheckABool
  9229.         tst.l    d0
  9230.         blt    ACommFail
  9231.         move.b    d0,LogCalls(a4)            ; Set mode
  9232.         CALLSYS    Forbid
  9233.         move.l    #GD_LogCall,d1
  9234.         lea    BillGads(a4),a0
  9235.         move.l    BillHandle(a4),a1
  9236.         RELLIB    SetCheckBox,_KCXBase
  9237.         CALLSYS    Permit
  9238.         bra    ARexxCommDone
  9239.  
  9240. ANoLogCalls    lea    BillWinStr(pc),a1        ; Popup billwindow on carrier detect ?
  9241.         bsr    CheckARexxComm
  9242.         bne.s    ANoBillPopUp
  9243.  
  9244.         bsr    CheckABool
  9245.         tst.l    d0
  9246.         blt    ACommFail
  9247.         move.b    d0,BillPopUp(a4)        ; set new state
  9248.         CALLSYS    Forbid
  9249.         move.l    #GD_PopUpBill,d1
  9250.         lea    PrefsGads(a4),a0
  9251.         move.l    PrefsHandle(a4),a1
  9252.         RELLIB    SetCheckBox,_KCXBase
  9253.         CALLSYS    Permit
  9254.         bra    ARexxCommDone
  9255.  
  9256. ANoBillPopUp    lea    ESCCloseStr(pc),a1        ; ESCClose active ?
  9257.         bsr    CheckARexxComm
  9258.         bne.s    ANoESCClose
  9259.  
  9260.         bsr    CheckABool
  9261.         tst.l    d0
  9262.         blt    ACommFail
  9263.         move.b    d0,ESCClose(a4)
  9264.         CALLSYS    Forbid
  9265.         move.l    #GD_ESCClose,d1
  9266.         lea    MiscGads(a4),a0
  9267.         move.l    MiscHandle(a4),a1
  9268.         RELLIB    SetCheckBox,_KCXBase
  9269.         CALLSYS    Permit
  9270.         bra    ARexxCommDone
  9271.  
  9272. ANoESCClose    lea    UmlautOnStr(pc),a1        ; Map Umlauts ?
  9273.         bsr    CheckARexxComm
  9274.         bne.s    ANoUmlautOn
  9275.  
  9276.         bsr    CheckABool
  9277.         tst.l    d0
  9278.         blt    ACommFail
  9279.         move.b    d0,MapUmlaut(a4)
  9280.         CALLSYS    Forbid
  9281.         move.l    #GD_MapUmlauts,d1
  9282.         lea    SetGads(a4),a0
  9283.         move.l    SetHandle(a4),a1
  9284.         RELLIB    SetCheckBox,_KCXBase
  9285.         CALLSYS    Permit
  9286.         bra    ARexxCommDone
  9287.  
  9288. ANoUmlautOn    lea    FKeysStr(pc),a1            ; Map FKeys ?
  9289.         bsr    CheckARexxComm
  9290.         bne.s    ANoFKeys
  9291.  
  9292.         bsr    CheckABool
  9293.         tst.l    d0
  9294.         blt    ACommFail
  9295.         move.b    d0,FKeysOn(a4)
  9296.         CALLSYS    Forbid
  9297.         move.l    #GD_FKeyAct,d1
  9298.         lea    FKeyGads(a4),a0
  9299.         move.l    FKeyHandle(a4),a1
  9300.         RELLIB    SetCheckBox,_KCXBase
  9301.         CALLSYS    Permit
  9302.         bra    ARexxCommDone
  9303.  
  9304. ANoFKeys    lea    EnableStr(pc),a1        ; Enable ?
  9305.         bsr    CheckARexxComm
  9306.         bne.s    ANoEnable
  9307.         clr.b    Disabled(a4)
  9308.         move.b    #1,TimeReset(a4)
  9309.         bsr    EnableBroker
  9310.         bra    ARexxCommDone
  9311.  
  9312. ANoEnable    lea    DisableStr(pc),a1        ; Disable ?
  9313.         bsr    CheckARexxComm
  9314.         bne.s    ANoDisable
  9315.         bsr    DisableBroker
  9316.         CALLSYS    Forbid
  9317.         bsr    OnScreen
  9318.         CALLSYS    Permit
  9319.         bsr    OnMouse
  9320.         move.b    #1,Disabled(a4)
  9321.         bra    ARexxCommDone
  9322.  
  9323. ANoDisable    lea    AReviseStr(pc),a1        ; Do revision ?
  9324.         bsr    CheckARexxComm
  9325.         bne    ANoRevise
  9326.         move.l    ARexxBuffer(a4),a1
  9327.         bsr    StrCpy
  9328.         move.l    ARexxBuffer(a4),a1
  9329.         move.l    a1,a0
  9330. .Loop        tst.b    (a1)                ; Get filename
  9331.         beq    ACommFail
  9332.         cmp.b    #' ',(a1)
  9333.         beq.s    GotFileName
  9334.         cmp.b    #'"',(a1)
  9335.         beq.s    GotFileName
  9336.         cmp.b    #"'",(a1)
  9337.         beq.s    GotFileName
  9338.         addq.l    #1,a1
  9339.         bra    .Loop
  9340. GotFileName    clr.b    (a1)+
  9341.         move.l    a1,a3
  9342.         lea    FileName(pc),a1            ; Copy filename
  9343.         bsr    StrCpy
  9344.         move.l    a3,a0
  9345.         bsr    SkipBlanks
  9346.         move.l    a0,a3
  9347.         lea    AReviseCStr(pc),a1        ; C or ASM revision ?
  9348.         bsr    CheckARexxComm2
  9349.         tst.l    d0
  9350.         bne.s    NoCMode
  9351.         move.l    #CRevDefine1,RevDefine        ; Set Pointer to macro text
  9352.         move.b    #'/',d0                ; First char of header
  9353.         move.b    #'*',d1                ; Line introducer
  9354.         move.b    d0,d2                ; Trailing char
  9355.         bra.s    GotMode
  9356. NoCMode        move.l    a3,a0
  9357.         lea    AReviseAsmStr(pc),a1
  9358.         bsr    CheckARexxComm2
  9359.         tst.l    d0
  9360.         bne.s    NoAsmMode
  9361.         move.l    #AsmRevDefine1,RevDefine    ; Pointer to defines
  9362.         move.b    #';',d0
  9363.         move.b    d0,d1
  9364.         move.b    #'*',d2
  9365.         bra.s    GotMode
  9366. NoAsmMode    move.l    a3,a0
  9367.         lea    ARevisePasStr(pc),a1
  9368.         bsr    CheckARexxComm2
  9369.         tst.l    d0
  9370.         bne.s    NoPasMode
  9371.         move.l    #PASRevDefine1,RevDefine    ; Pointer to defines
  9372.         move.b    #'{',d0
  9373.         move.b    #'*',d1
  9374.         move.b    #'}',d2
  9375.         bra.s    GotMode
  9376. NoPasMode    move.l    a3,a0
  9377.         lea    AReviseBasStr(pc),a1
  9378.         bsr    CheckARexxComm2
  9379.         tst.l    d0
  9380.         bne    ACommFail
  9381.         move.l    #BASRevDefine1,RevDefine    ; Pointer to defines
  9382.         move.b    #"'",d0
  9383.         move.b    d0,d1
  9384.         move.b    #'*',d2
  9385. GotMode        bsr    DoRevision
  9386.         tst.l    d0
  9387.         beq    ACommFail
  9388.         bra    ARexxCommDone
  9389.  
  9390. ANoRevise    lea    DriveStr(pc),a1            ; Set new drive ?
  9391.         bsr    CheckARexxComm
  9392.         bne.s    ANoDrive
  9393.  
  9394.         link    a5,#-4
  9395.         move.l    a0,d1
  9396.         lea    -4(a5),a0
  9397.         move.l    a0,d2
  9398.         RELLIB    StrToLong,_DOSBase
  9399.         move.l    -4(a5),d1
  9400.         unlk    a5
  9401.         tst.l    d0
  9402.         beq    ACommFail
  9403.         move.l    d1,d0
  9404.         lea    DriveRequests(a4),a0
  9405.         lsl.l    #2,d0
  9406.         tst.l    0(a0,d0.w)
  9407.         beq    ACommFail
  9408.         move.w    d1,FormatDrive(a4)
  9409.  
  9410.         CALLSYS    Forbid
  9411.         move.l    #GD_Drive,d0            ; Set Drive gadget
  9412.         moveq    #0,d1
  9413.         move.w    FormatDrive(a4),d1
  9414.         lea    FormGads(a4),a0
  9415.         move.l    FormHandle(a4),a1
  9416.         lea    DriveList(a4),a2
  9417.         RELLIB    SetCycleGad,_KCXBase
  9418.         CALLSYS    Permit
  9419.         bra    ARexxCommDone
  9420.  
  9421. ANoDrive    lea    LabelStr(pc),a1            ; new label ?
  9422.         bsr    CheckARexxComm
  9423.         bne.s    ANoLabel
  9424.  
  9425.         lea    FormatDriveName(a4),a1
  9426.         move.l    #29,d7
  9427.         bsr    StrNCpy
  9428.         CALLSYS    Forbid
  9429.         move.l    #GD_Label,d0
  9430.         lea    FormGads(a4),a0
  9431.         move.l    FormHandle(a4),a1
  9432.         move.l    #30,d1
  9433.         lea    FormatDriveName(a4),a2
  9434.         RELLIB    SetStringGad,_KCXBase
  9435.         CALLSYS    Permit
  9436.         bra    ARexxCommDone
  9437.  
  9438. ANoLabel    lea    AIconStr(pc),a1            ; Create Trashcan ?
  9439.         bsr    CheckARexxComm
  9440.         bne.s    ANoTrash
  9441.  
  9442.         bsr    CheckABool
  9443.         tst.l    d0
  9444.         blt    ACommFail
  9445.         CALLSYS    Forbid
  9446.         move.b    d0,MakeIcons(a4)
  9447.         move.l    #GD_Trashcan,d1
  9448.         bsr    SetFormBox
  9449.         CALLSYS    Permit
  9450.         bra    ARexxCommDone
  9451.  
  9452. ANoTrash    lea    QuickStr(pc),a1            ; Quick format ?
  9453.         bsr    CheckARexxComm
  9454.         bne.s    ANoQuick
  9455.  
  9456.         bsr    CheckABool
  9457.         tst.l    d0
  9458.         blt    ACommFail
  9459.         CALLSYS    Forbid
  9460.         move.b    d0,QuickFormat(a4)
  9461.         move.l    #GD_Quick,d1
  9462.         bsr    SetFormBox
  9463.         CALLSYS    Permit
  9464.         bra    ARexxCommDone
  9465.  
  9466. ANoQuick    lea    FFSStr(pc),a1            ; Format FFS ?
  9467.         bsr    CheckARexxComm
  9468.         bne.s    ANoFFS
  9469.  
  9470.         bsr    CheckABool
  9471.         tst.l    d0
  9472.         blt    ACommFail
  9473.         CALLSYS    Forbid
  9474.         move.b    d0,FFSDrive(a4)
  9475.         move.l    #GD_FFS,d1
  9476.         bsr    SetFormBox
  9477.         CALLSYS    Permit
  9478.         bra    ARexxCommDone
  9479.  
  9480. ANoFFS        lea    VerifyStr(pc),a1        ; Verify format ?
  9481.         bsr    CheckARexxComm
  9482.         bne.s    ANoVerify
  9483.  
  9484.         bsr    CheckABool
  9485.         tst.l    d0
  9486.         blt    ACommFail
  9487.         CALLSYS    Forbid
  9488.         move.b    d0,NoVerify(a4)
  9489.         move.l    #GD_NoVerify,d1
  9490.         bsr    SetFormBox
  9491.         CALLSYS    Permit
  9492.         bra    ARexxCommDone
  9493.  
  9494. ANoVerify    lea    InstallStr(pc),a1        ; Install disk ?
  9495.         bsr    CheckARexxComm
  9496.         bne.s    ANoInstall
  9497.  
  9498.         bsr    CheckABool
  9499.         tst.l    d0
  9500.         blt    ACommFail
  9501.         CALLSYS    Forbid
  9502.         move.b    d0,Install(a4)
  9503.         move.l    #GD_Install,d1
  9504.         bsr    SetFormBox
  9505.         CALLSYS    Permit
  9506.         bra    ARexxCommDone
  9507.  
  9508. ANoInstall    lea    EjectStr(pc),a1            ; Eject disk ?
  9509.         bsr    CheckARexxComm
  9510.         bne.s    ANoEject
  9511.  
  9512.         bsr    CheckABool
  9513.         tst.l    d0
  9514.         blt    ACommFail
  9515.         CALLSYS    Forbid
  9516.         move.b    d0,EjectDrive(a4)
  9517.         move.l    #GD_Eject,d1
  9518.         bsr    SetFormBox
  9519.         CALLSYS    Permit
  9520.         bra    ARexxCommDone
  9521.  
  9522. ANoEject    lea    InterStr(pc),a1            ; International mode ?
  9523.         bsr    CheckARexxComm
  9524.         bne.s    ANoInter
  9525.  
  9526.         bsr    CheckABool
  9527.         tst.l    d0
  9528.         blt    ACommFail
  9529.         CALLSYS    Forbid
  9530.         tst.b    DirCache(a4)
  9531.         bne.s    .End
  9532.         move.b    d0,InterMode(a4)
  9533.         move.b    d0,OldInterMode(a4)
  9534.         move.l    #GD_IntMode,d1
  9535.         bsr    SetFormBox
  9536. .End        CALLSYS    Permit
  9537.         bra    ARexxCommDone
  9538.  
  9539. ANoInter    lea    CacheStr(pc),a1            ; Caching ?
  9540.         bsr    CheckARexxComm
  9541.         bne.s    ANoCache
  9542.  
  9543.         bsr    CheckABool
  9544.         tst.l    d0
  9545.         blt    ACommFail
  9546.         CALLSYS    Forbid
  9547.         move.b    d0,DirCache(a4)
  9548.         tst.b    d0
  9549.         beq.s    .UseOldInt
  9550.         moveq    #1,d0
  9551.         move.b    d0,InterMode(a4)
  9552.         moveq    #1,d2
  9553.         bra.s    .SetGad
  9554. .UseOldInt    move.b    OldInterMode(a4),d0
  9555.         move.b    d0,InterMode(a4)
  9556.         moveq    #0,d2
  9557. .SetGad        move.l    #GD_IntMode,d1
  9558.         bsr    SetFormBox
  9559.         move.l    #GD_IntMode,d0
  9560.         move.l    d2,d1
  9561.         DOLIB    GhostGadget
  9562.         move.b    DirCache(a4),d0
  9563.         move.l    #GD_DiskCache,d1
  9564.         bsr    SetFormBox
  9565.         CALLSYS    Permit
  9566.         bra    ARexxCommDone
  9567.  
  9568. ANoCache    lea    WatchStr(pc),a1            ; Watch disks ?
  9569.         bsr    CheckARexxComm
  9570.         bne.s    ANoWatch
  9571.  
  9572.         bsr    CheckABool
  9573.         tst.l    d0
  9574.         blt    ACommFail
  9575.         CALLSYS    Forbid
  9576.         move.b    d0,WatchDisks(a4)
  9577.         move.l    #GD_WatchDisks,d1
  9578.         bsr    SetFormBox
  9579.         CALLSYS    Permit
  9580.         bra    ARexxCommDone
  9581.  
  9582. ANoWatch    lea    FormatStr(pc),a1        ; Do format ???
  9583.         bsr    CheckARexxComm
  9584.         bne.s    ANoFormat
  9585.         bsr    GoGoGoFormat
  9586.         bra.s    ARexxCommDone
  9587.  
  9588. ANoFormat    lea    TimeZoneStr(pc),a1        ; Change timezone ?
  9589.         bsr    CheckARexxComm
  9590.         bne.s    ARexxCommDone
  9591.         move.l    TimeZone(a4),d7
  9592.         move.l    ARexxBuffer(a4),a1
  9593.         bsr    StrCpy
  9594.         move.l    ARexxBuffer(a4),d1
  9595.         lea    TimeZone(a4),a0
  9596.         move.l    a0,d2
  9597.         RELLIB    StrToLong,_DOSBase        ; Get new time
  9598.         tst.l    TimeZone(a4)            ; negative ?
  9599.         blt.s    .Error                ; disable blank
  9600.         cmp.l    #3,d0
  9601.         blt.s    .GoOn
  9602. .Error        move.l    d7,TimeZone(a4)
  9603. .GoOn        CALLSYS    Forbid
  9604.         move.l    #GD_BillTimeMX,d0
  9605.         move.l    TimeZone(a4),d1
  9606.         lea    BillGads(a4),a0
  9607.         move.l    BillHandle(a4),a1
  9608.         RELLIB    SetMXGad,_KCXBase
  9609.         CALLSYS    Permit
  9610.         bra.s    ARexxCommDone
  9611.  
  9612. ACommFail    move.l    #RC_FAIL,AResult1(a4)        ; Command failed
  9613.         clr.l    AResult2(a4)
  9614. ARexxCommDone    move.l    MyARexxMsg(a4),a1
  9615.         move.l    AResult1(a4),rm_Result1(a1)
  9616.         move.l    AResult2(a4),rm_Result2(a1)
  9617.         CALLSYS    ReplyMsg
  9618.         bra    HandleARexx
  9619. AllARexxDone    rts
  9620.  
  9621. **********************************************************************
  9622. *                          ARexx variables                           *
  9623. **********************************************************************
  9624. ActivateStr    dc.b    "ACTIVATE",0
  9625. MouseStr    dc.b    "SUNMOUSE",0
  9626. MenuWrapStr    dc.b    "MENUWRAP",0
  9627. FKeysStr    dc.b    "FKEYS",0
  9628. PageNumStr    dc.b    "PAGENUM",0
  9629. SetEnvStr    dc.b    "SETENV",0
  9630. ScreenTStr    dc.b    "SCREENTIME",0
  9631. MouseTStr    dc.b    "MOUSETIME",0
  9632. CycleWStr    dc.b    "CYCLING",0
  9633. BillWinStr    dc.b    "BILLPOPUP",0
  9634. LogCallStr    dc.b    "LOGCALLS",0
  9635. ESCCloseStr    dc.b    "ESCCLOSE",0
  9636. UmlautOnStr    dc.b    "MAPUMLAUT",0
  9637. DriveStr    dc.b    "DRIVE",0
  9638. LabelStr    dc.b    "LABEL",0
  9639. AIconStr    dc.b    "TRASHCAN",0
  9640. QuickStr    dc.b    "QUICK",0
  9641. FFSStr        dc.b    "FFS",0
  9642. VerifyStr    dc.b    "NOVERIFY",0
  9643. InstallStr    dc.b    "INSTALL",0
  9644. EjectStr    dc.b    "EJECT",0
  9645. InterStr    dc.b    "INTERNATIONAL",0
  9646. CacheStr    dc.b    "DIRCACHE",0
  9647. WatchStr    dc.b    "WATCHDISKS",0
  9648. FormatStr    dc.b    "FORMAT",0
  9649. TimeZoneStr    dc.b    "TIMEZONE",0
  9650. EnableStr    dc.b    "ENABLE",0
  9651. DisableStr    dc.b    "DISABLE",0
  9652. AReviseStr    dc.b    "REVISE",0
  9653. AReviseAsmStr    dc.b    "ASM",0
  9654. AReviseCStr    dc.b    "C",0
  9655. ARevisePasStr    dc.b    "PAS",0
  9656. AReviseBasStr    dc.b    "BAS",0
  9657.         EVEN
  9658.  
  9659.  
  9660.  
  9661. **********************************************************************
  9662. *                Checks, if we know the ARexx command                *
  9663. **********************************************************************
  9664. CheckARexxComm    move.l    ARexxCommand(a4),a0
  9665. CheckARexxComm2    moveq    #0,d0
  9666.         moveq    #0,d1
  9667. .Loop        move.b    (a0)+,d0            ; Get chars from buffer
  9668.         move.b    (a1)+,d1
  9669.         or.b    #$20,d0                ; Make it case in-sensitive
  9670.         or.b    #$20,d1
  9671.         cmp.b    #$20,d0                ; Argstring end ?
  9672.         beq.s    .StringOk
  9673.         cmp.b    d0,d1
  9674.         beq.s    .Loop
  9675. .StringFalse    moveq    #1,d0                ; Error flag
  9676.         rts
  9677. .StringOk    cmp.b    #$20,d1                ; Our string also ending ?
  9678.         bne    .StringFalse            ; Nope -> go on
  9679.         bsr    SkipBlanks
  9680.         moveq    #0,d0                ; Command OK
  9681.         tst.l    d0
  9682.         rts
  9683.  
  9684.  
  9685. **********************************************************************
  9686. *             Checks for flags (0/1) in an ARexx-Command             *
  9687. **********************************************************************
  9688. CheckABool    cmp.b    #'0',(a0)
  9689.         beq.s    .False
  9690.         cmp.b    #'1',(a0)
  9691.         beq.s    .True
  9692.         moveq    #-1,d0
  9693.         rts
  9694. .False        moveq    #0,d0
  9695.         rts
  9696. .True        moveq    #1,d0
  9697.         rts
  9698.  
  9699.  
  9700.  
  9701.  
  9702. **********************************************************************
  9703. *              Enter a log message and revise the text               *
  9704. **********************************************************************
  9705. DoRevision    clr.l    OurLock(a4)
  9706.  
  9707.         move.b    d0,CHeader            ; Write chars to Header
  9708.         move.b    d1,CLineNL            ; for different languages
  9709.         move.b    d1,CLine
  9710.         move.b    d1,CCopyRight
  9711.         move.b    d1,CCR1
  9712.         move.b    d1,CFile
  9713.         move.b    d1,CCreatedOn
  9714.         move.b    d1,CAuthor
  9715.         move.b    d1,CRevision
  9716.         move.b    d1,CPurpose
  9717.         move.b    d1,CPurpose+3
  9718.         move.b    d1,CPurpose+6
  9719.         move.b    d1,CPurpose+17
  9720.         move.b    d1,CLog
  9721.         move.b    d1,CL1
  9722.         move.b    d1,CL2
  9723.         move.b    d1,CL3
  9724.         move.b    d1,CLogInit
  9725.         move.b    d1,CLI1
  9726.         move.b    d1,CLI2
  9727.         move.b    d1,CLI3
  9728.         move.b    d1,CLI4
  9729.         move.b    d1,CLI5
  9730.         move.b    d1,CEnd
  9731.         move.b    d2,CEnd+81
  9732.         move.b    d1,CNewLog
  9733.  
  9734.         lea    RevDateTime(a4),a0
  9735.         move.l    a0,d1
  9736.         RELLIB    DateStamp,_DOSBase
  9737.  
  9738.         lea    RevDateTime(a4),a0        ; Get day string
  9739.         move.l    ds_Days(a0),d0
  9740.         divu    #7,d0
  9741.         clr.w    d0
  9742.         swap    d0
  9743.         lsl.l    #2,d0
  9744.         lea    RevDays(pc),a0
  9745.         move.l    0(a0,d0.w),a0            ; Copy day name to buffer
  9746.         lea    RevDayString(pc),a1
  9747.         bsr    StrCpy
  9748.  
  9749.         lea    RevDateTime(a4),a0        ; Do the string formatings
  9750.         move.b    #FORMAT_CDN,dat_Format(a0)
  9751.         clr.l    dat_StrDay(a0)            ; First create the whole string
  9752.         lea    RevDateString(pc),a1
  9753.         move.l    a1,dat_StrDate(a0)        ; for revision
  9754.         lea    RevTimeString(pc),a1
  9755.         move.l    a1,dat_StrTime(a0)
  9756.         move.l    a0,d1
  9757.         DOLIB    DateToStr
  9758.         lea    RevDateString(pc),a0
  9759.         move.b    #'.',2(a0)
  9760.         move.b    #'.',5(a0)
  9761.  
  9762.         lea    FileName(pc),a0
  9763. .LoopDev    cmp.b    #':',(a0)            ; Find out whether filename
  9764.         beq.s    .GotDev                ; is given with complete path
  9765.         tst.b    (a0)
  9766.         beq.s    .NoDev
  9767.         addq.l    #1,a0
  9768.         bra.s    .LoopDev
  9769.  
  9770. .NoDev        move.l    MyARexxMsg(a4),a0        ; Lock to current Dir of
  9771.         move.l    MN_REPLYPORT(a0),a0        ; ARexx. Normaly the workdirectory
  9772.         move.l    MP_SIGTASK(a0),a0        ; your editor is running on.
  9773.         move.l    pr_CurrentDir(a0),d1        ; If a path is specified
  9774.         RELLIB    DupLock,_DOSBase
  9775.         move.l    d0,OurLock(a4)
  9776.         beq    NoRevision
  9777.         move.l    d0,d1
  9778.         DOLIB    CurrentDir
  9779.         move.l    d0,PastLock(a4)
  9780.         beq    NoRevision
  9781.  
  9782. .GotDev        bsr    CheckRevision            ; Check if Revision already there
  9783.         tst.l    d7
  9784.         blt    NoRevision
  9785.  
  9786.         link    a5,#-(4+4+2+2+2+2+gng_SIZEOF)
  9787.         lea    LogTxt(a4),a0
  9788.         move.l    a0,FontPtr(a5)
  9789.         bsr    LockScreen
  9790.         tst.l    d0
  9791.         beq    .LogWinError
  9792.         move.l    d0,a0
  9793.         RELLIB    ScreenToFront,_IntuitionBase
  9794.         moveq    #0,d2
  9795.         moveq    #0,d3
  9796.         RELLIB    ComputeFont,_KCXBase
  9797.         move.l    -4(a5),a0
  9798.         sub.l    a1,a1
  9799.         RELLIB    GetVisualInfoA,_GadToolsBase
  9800.         move.l    d0,LogVisInfo(a4)
  9801.         beq    .LogWinError
  9802.  
  9803.         move.l    -4(a5),a0
  9804.         moveq    #0,d3
  9805.         moveq    #0,d2
  9806.         move.w    LogWinWidth(a4),d2
  9807.         move.w    LogWinHeight(a4),d3
  9808.         RELLIB    ComputeFont,_KCXBase
  9809.         move.l    -4(a5),a0
  9810.         move.l    d2,d0
  9811.         DOLIB    ComputeX
  9812.         move.l    d0,d4
  9813.         move.w    LogWinLeft(a4),d2
  9814.         move.l    -4(a5),a3
  9815.         move.w    sc_LeftEdge(a3),d5
  9816.         neg.w    d5
  9817.         add.w    d5,d2
  9818.         add.w    d2,d0
  9819.         add.w    OffX(a5),d0
  9820.         moveq    #0,d1
  9821.         move.b    sc_WBorRight(a0),d1
  9822.         add.w    d1,d0
  9823.         cmp.w    sc_Width(a0),d0
  9824.         bls.s    .WOk
  9825.         move.w    sc_Width(a0),d0
  9826.         sub.w    d4,d0
  9827.         move.w    d0,d2
  9828. .WOk        move.l    d3,d0
  9829.         DOLIB    ComputeY
  9830.         move.l    d0,d4
  9831.         move.w    LogWinTop(a4),d3
  9832.         move.l    -4(a5),a3
  9833.         move.w    sc_TopEdge(a3),d5
  9834.         neg.w    d5
  9835.         add.w    d5,d3
  9836.         add.w    d3,d0
  9837.         add.w    OffY(a5),d0
  9838.         moveq    #0,d1
  9839.         move.b    sc_WBorBottom(a0),d1
  9840.         add.w    d1,d0
  9841.         cmp.w    sc_Height(a0),d0
  9842.         bls.s    .HOk
  9843.         move.w    sc_Height(a0),d0
  9844.         sub.w    d4,d0
  9845.         move.w    d0,d3
  9846. .HOk        lea.l    LogGadget(a4),a0
  9847.         RELLIB    CreateContext,_GadToolsBase
  9848.         move.l    d0,a3
  9849.         beq    .LogWinError
  9850.  
  9851.         movem.l d2-d3/a4,-(sp)
  9852.         moveq    #0,d3
  9853.         lea.l    LogWinGTags,a4
  9854. .LogWinGL    lea.l    LogWinNGads,a0
  9855.         move.l    d3,d0
  9856.         mulu    #gng_SIZEOF,d0
  9857.         add.l    d0,a0
  9858.         lea.l    -(4+4+2+2+2+2+gng_SIZEOF)(a5),a1
  9859.         moveq    #gng_SIZEOF,d0
  9860.         CALLSYS    CopyMem
  9861.         lea.l    -(4+4+2+2+2+2+gng_SIZEOF)(a5),a0
  9862.         move.l    a4,-(sp)
  9863.         move.l    ZeroBase(pc),a4
  9864.         move.l    gng_GadgetText(a0),-(sp)
  9865.         bsr    GetLocStr
  9866.         move.l    (sp)+,d7
  9867.         move.l    d7,gng_GadgetText(a0)
  9868.         move.l    LogVisInfo(a4),gng_VisualInfo(a0)
  9869.         move.l    FontPtr(a5),gng_TextAttr(a0)
  9870.         move.w    gng_LeftEdge(a0),d0
  9871.         RELLIB    ComputeX,_KCXBase
  9872.         move.l    (sp)+,a4
  9873.         add.w    OffX(a5),d0
  9874.         move.w    d0,gng_LeftEdge(a0)
  9875.         move.w    gng_TopEdge(a0),d0
  9876.         DOLIB    ComputeY
  9877.         add.w    OffY(a5),d0
  9878.         move.w    d0,gng_TopEdge(a0)
  9879.         move.w    gng_Width(a0),d0
  9880.         DOLIB    ComputeX
  9881.         move.w    d0,gng_Width(a0)
  9882.         move.w    gng_Height(a0),d0
  9883.         DOLIB    ComputeY
  9884.         move.w    d0,gng_Height(a0)
  9885.         lea.l    LogWinGTypes,a0
  9886.         moveq    #0,d0
  9887.         move.l    d3,d1
  9888.         lsl.l    #1,d1
  9889.         move.w    0(a0,d1.w),d0
  9890.         move.l    a3,a0
  9891.         lea.l    -(4+4+2+2+2+2+gng_SIZEOF)(a5),a1
  9892.         move.l    a4,a2
  9893.         move.l    a4,-(sp)
  9894.         move.l    ZeroBase(pc),a4
  9895.         RELLIB    CreateGadgetA,_GadToolsBase
  9896.         move.l    (sp)+,a4
  9897.         tst.l    d0
  9898.         beq    .LogWinError
  9899.         move.l    d0,a3
  9900.         move.l    d7,a0
  9901.         bsr    LocalizeGadKey
  9902.         move.l    d1,gg_UserData(a3)
  9903.         move.l    d3,d0
  9904.         lsl.l    #2,d0
  9905.         move.l    a4,-(sp)
  9906.         move.l    ZeroBase(pc),a4
  9907.         lea.l    LogGads(a4),a0
  9908.         move.l    (sp)+,a4
  9909.         move.l    a3,0(a0,d0.w)
  9910. .LogWinTL    tst.l    (a4)
  9911.         beq.s    .LogWinDN
  9912.         addq.w    #8,a4
  9913.         bra.s    .LogWinTL
  9914. .LogWinDN    addq.w    #4,a4
  9915.         addq.w    #1,d3
  9916.         cmp.w    #LogWin_CNT,d3
  9917.         bmi    .LogWinGL
  9918.         movem.l (sp)+,d2-d3/a4
  9919.         move.l    LogGadget(a4),LogWinWG+4
  9920.  
  9921.         lea    LogGads(a4),a0
  9922.         bsr    SetStrIntGads
  9923.  
  9924.         move.l    -4(a5),LogWinSC+4        ; Open window
  9925.         ext.l    d2
  9926.         ext.l    d3
  9927.         move.l    d2,LogWinL+4
  9928.         move.l    d3,LogWinT+4
  9929.         move.l    -4(a5),a0
  9930.         move.w    LogWinWidth(a4),d0
  9931.         RELLIB    ComputeX,_KCXBase
  9932.         add.w    OffX(a5),d0
  9933.         moveq    #0,d1
  9934.         move.b    sc_WBorRight(a0),d1
  9935.         add.w    d1,d0
  9936.         move.l    d0,LogWinW+4
  9937.         move.w    LogWinHeight(a4),d0
  9938.         DOLIB    ComputeY
  9939.         add.w    OffY(a5),d0
  9940.         moveq    #0,d1
  9941.         move.b    sc_WBorBottom(a0),d1
  9942.         add.w    d1,d0
  9943.         move.l    d0,LogWinH+4
  9944.         suba.l    a0,a0
  9945.         lea.l    LogWinWindowTags,a1
  9946.         RELLIB    OpenWindowTagList,_IntuitionBase
  9947.         move.l    d0,LogHandle(a4)
  9948.         beq.s    .LogWinError
  9949.  
  9950.         move.l    LogHandle(a4),a0
  9951.         suba.l    a1,a1
  9952.         RELLIB    GT_RefreshWindow,_GadToolsBase
  9953.  
  9954.         move.l    #GD_LogVer,d0
  9955.         move.w    RevRevisionDat(pc),d1
  9956.         lea    LogGads(a4),a0
  9957.         move.l    LogHandle(a4),a1
  9958.         RELLIB    SetIntegerGad,_KCXBase
  9959.         move.l    #GD_LogRev,d0
  9960.         move.w    RevRevisionDat+2(pc),d1
  9961.         DOLIB    SetIntegerGad
  9962.         move.l    #GD_LogOnlyText,d0
  9963.         moveq    #0,d1
  9964.         move.b    OnlyLog(a4),d1
  9965.         bchg    #0,d1
  9966.         DOLIB    GhostGadget
  9967.  
  9968.         bsr    UnlockScreen
  9969.         unlk    a5
  9970.         bra.s    .GotLogWin
  9971. .LogWinError    bsr    UnlockScreen
  9972.         unlk    a5
  9973.         bra    NoLogWin
  9974.  
  9975. .GotLogWin    lea    NewMsg(a4),a1            ; and messages
  9976.         move.w    #(62*5)-1,d7
  9977. .Loop1        clr.b    (a1)+
  9978.         dbf    d7,.Loop1
  9979.  
  9980.         tst.b    OnlyLog(a4)            ; Enter a new LogMessage ?
  9981.         bne.s    DoOnlyLog
  9982.         move.l    LogHandle(a4),a0        ; Set window title for purpose
  9983.         LOCLEA    PurposeWinTitle,a1
  9984.         suba.l    a2,a2
  9985.         subq.w    #1,a2
  9986.         RELLIB    SetWindowTitles,_IntuitionBase
  9987.         bsr    CheckRevInput
  9988.         cmp.b    #2,LogInputEnd(a4)
  9989.         beq    NoErrorFound
  9990.         lea    NewMsg(a4),a3
  9991.         bsr    CopyMessage            ; Copy entered message
  9992.         bra.s    PurpDone
  9993.  
  9994. DoOnlyLog    move.l    LogHandle(a4),a0        ; Change to log title
  9995.         LOCLEA    LogWinTitle,a1
  9996.         suba.l    a2,a2
  9997.         subq.w    #1,a2
  9998.         RELLIB    SetWindowTitles,_IntuitionBase
  9999.         bsr    CheckRevInput
  10000.         cmp.b    #2,LogInputEnd(a4)
  10001.         beq    NoErrorFound
  10002.         lea    NewMsg(a4),a3
  10003.         bsr    CopyMessage            ; Copy entered message
  10004.  
  10005. PurpDone    link    a5,#-(4+4+2+2+2+2+20+gng_SIZEOF)
  10006.         lea    ProgTxt(a4),a0
  10007.         move.l    a0,FontPtr(a5)
  10008.         bsr    LockScreen
  10009.         tst.l    d0
  10010.         beq    .ProgWinError
  10011.         moveq    #0,d2
  10012.         moveq    #0,d3
  10013.         RELLIB    ComputeFont,_KCXBase
  10014.         move.l    -4(a5),a0
  10015.         sub.l    a1,a1
  10016.         RELLIB    GetVisualInfoA,_GadToolsBase
  10017.         move.l    d0,ProgVisInfo(a4)
  10018.         beq    .ProgWinError
  10019.  
  10020.         move.l    -4(a5),a0
  10021.         moveq    #0,d3
  10022.         moveq    #0,d2
  10023.         move.w    ProgWinWidth(a4),d2
  10024.         move.w    ProgWinHeight(a4),d3
  10025.         RELLIB    ComputeFont,_KCXBase
  10026.         move.l    -4(a5),a0
  10027.         move.l    d2,d0
  10028.         DOLIB    ComputeX
  10029.         move.l    d0,d4
  10030.         move.w    ProgWinLeft(a4),d2
  10031.         move.l    -4(a5),a3
  10032.         move.w    sc_LeftEdge(a3),d5
  10033.         neg.w    d5
  10034.         add.w    d5,d2
  10035.         add.w    d2,d0
  10036.         add.w    OffX(a5),d0
  10037.         moveq    #0,d1
  10038.         move.b    sc_WBorRight(a0),d1
  10039.         add.w    d1,d0
  10040.         cmp.w    sc_Width(a0),d0
  10041.         bls.s    .WOk
  10042.         move.w    sc_Width(a0),d0
  10043.         sub.w    d4,d0
  10044.         move.w    d0,d2
  10045. .WOk        move.l    d3,d0
  10046.         DOLIB    ComputeY
  10047.         move.l    d0,d4
  10048.         move.w    ProgWinTop(a4),d3
  10049.         move.l    -4(a5),a3
  10050.         move.w    sc_TopEdge(a3),d5
  10051.         neg.w    d5
  10052.         add.w    d5,d3
  10053.         add.w    d3,d0
  10054.         add.w    OffY(a5),d0
  10055.         moveq    #0,d1
  10056.         move.b    sc_WBorBottom(a0),d1
  10057.         add.w    d1,d0
  10058.         cmp.w    sc_Height(a0),d0
  10059.         bls.s    .HOk
  10060.         move.w    sc_Height(a0),d0
  10061.         sub.w    d4,d0
  10062.         move.w    d0,d3
  10063. .HOk        lea.l    ProgGadget(a4),a0
  10064.         RELLIB    CreateContext,_GadToolsBase
  10065.         move.l    d0,a3
  10066.         beq    .ProgWinError
  10067.  
  10068.         movem.l d2-d3/a4,-(sp)
  10069.         moveq    #0,d3
  10070.         lea.l    ProgWinGTags,a4
  10071. .ProgWinGL    lea.l    ProgWinNGads,a0
  10072.         move.l    d3,d0
  10073.         mulu    #gng_SIZEOF,d0
  10074.         add.l    d0,a0
  10075.         lea.l    -(4+4+2+2+2+2+gng_SIZEOF)(a5),a1
  10076.         moveq    #gng_SIZEOF,d0
  10077.         CALLSYS    CopyMem
  10078.         lea.l    -(4+4+2+2+2+2+gng_SIZEOF)(a5),a0
  10079.         move.l    a4,-(sp)
  10080.         move.l    ZeroBase(pc),a4
  10081.         move.l    ProgVisInfo(a4),gng_VisualInfo(a0)
  10082.         move.l    FontPtr(a5),gng_TextAttr(a0)
  10083.         move.w    gng_LeftEdge(a0),d0
  10084.         RELLIB    ComputeX,_KCXBase
  10085.         move.l    (sp)+,a4
  10086.         add.w    OffX(a5),d0
  10087.         move.w    d0,gng_LeftEdge(a0)
  10088.         move.w    gng_TopEdge(a0),d0
  10089.         DOLIB    ComputeY
  10090.         add.w    OffY(a5),d0
  10091.         move.w    d0,gng_TopEdge(a0)
  10092.         move.w    gng_Width(a0),d0
  10093.         DOLIB    ComputeX
  10094.         move.w    d0,gng_Width(a0)
  10095.         move.w    gng_Height(a0),d0
  10096.         DOLIB    ComputeY
  10097.         move.w    d0,gng_Height(a0)
  10098.         lea.l    ProgWinGTypes,a0
  10099.         moveq    #0,d0
  10100.         move.l    d3,d1
  10101.         lsl.l    #1,d1
  10102.         move.w    0(a0,d1.w),d0
  10103.         move.l    a3,a0
  10104.         lea.l    -(4+4+2+2+2+2+gng_SIZEOF)(a5),a1
  10105.         move.l    a4,a2
  10106.         move.l    a4,-(sp)
  10107.         move.l    ZeroBase(pc),a4
  10108.         RELLIB    CreateGadgetA,_GadToolsBase
  10109.         move.l    (sp)+,a4
  10110.         tst.l    d0
  10111.         beq    .ProgWinError
  10112.         move.l    d0,a3
  10113. .ProgWinTL    tst.l    (a4)
  10114.         beq.s    .ProgWinDN
  10115.         addq.w    #8,a4
  10116.         bra.s    .ProgWinTL
  10117. .ProgWinDN    addq.w    #4,a4
  10118.         addq.w    #1,d3
  10119.         cmp.w    #ProgWin_CNT,d3
  10120.         bmi    .ProgWinGL
  10121.         movem.l (sp)+,d2-d3/a4
  10122.         move.l    ProgGadget(a4),ProgWinWG+4
  10123.  
  10124.         LOCLEA    ProgWinWTitle,ProgWinWG+12
  10125.         LOCLEA    WindowScrTitle,ProgWinWG+20
  10126.         move.l    -4(a5),ProgWinSC+4        ; Open window
  10127.         ext.l    d2
  10128.         ext.l    d3
  10129.         move.l    d2,ProgWinL+4
  10130.         move.l    d3,ProgWinT+4
  10131.         move.l    -4(a5),a0
  10132.         move.w    ProgWinWidth(a4),d0
  10133.         RELLIB    ComputeX,_KCXBase
  10134.         add.w    OffX(a5),d0
  10135.         moveq    #0,d1
  10136.         move.b    sc_WBorRight(a0),d1
  10137.         add.w    d1,d0
  10138.         move.l    d0,ProgWinW+4
  10139.         move.w    ProgWinHeight(a4),d0
  10140.         DOLIB    ComputeY
  10141.         add.w    OffY(a5),d0
  10142.         moveq    #0,d1
  10143.         move.b    sc_WBorBottom(a0),d1
  10144.         add.w    d1,d0
  10145.         move.l    d0,ProgWinH+4
  10146.         suba.l    a0,a0
  10147.         lea.l    ProgWinWindowTags,a1
  10148.         RELLIB    OpenWindowTagList,_IntuitionBase
  10149.         move.l    d0,ProgHandle(a4)
  10150.         beq    .ProgWinError
  10151.         move.l    d0,a0
  10152.         move.l    wd_RPort(a0),ProgRPort(a4)
  10153.         suba.l    a1,a1
  10154.         RELLIB    GT_RefreshWindow,_GadToolsBase
  10155.  
  10156.         moveq    #0,d2
  10157.         moveq    #0,d3
  10158.         move.w    ProgWinWidth(a4),d2
  10159.         move.w    ProgWinHeight(a4),d3
  10160.         RELLIB    ComputeFont,_KCXBase
  10161.  
  10162.         move.l    ProgRPort(a4),a0
  10163.         lea.l    -(4+4+2+2+2+2+20)(a5),a1    ; Set Bevel tag
  10164.         move.l    #GTBB_Recessed,(a1)
  10165.         move.l    #-1,4(a1)
  10166.         move.l    #GT_VisualInfo,8(a1)
  10167.         move.l    ProgVisInfo(a4),12(a1)
  10168.         move.l    #TAG_DONE,16(a1)
  10169.         moveq    #4,d0
  10170.         DOLIB    ComputeY
  10171.         add.w    OffY(a5),d0
  10172.         move.l    d0,d1
  10173.         move.l    #221,d0
  10174.         DOLIB    ComputeX
  10175.         move.l    d0,d2
  10176.         move.l    #16,d0
  10177.         DOLIB    ComputeY
  10178.         move.l    d0,d3
  10179.         move.l    #39,d0
  10180.         DOLIB    ComputeX
  10181.         add.w    OffX(a5),d0
  10182.         RELLIB    DrawBevelBoxA,_GadToolsBase
  10183.  
  10184.         bsr    UnlockScreen
  10185.         unlk    a5
  10186.         bra.s    .ProgOpen
  10187.  
  10188. .ProgWinError    bsr    UnlockScreen
  10189.         unlk    a5
  10190.         bra    NoLogWin
  10191.  
  10192. .ProgOpen    move.l    LogHandle(a4),a0
  10193.         RELLIB    BusyWindow,_KCXBase
  10194.  
  10195.         lea    Author(pc),a0
  10196.         move.l    a0,RevAuthorDat            ; Set strings to defaults
  10197.         lea    Company(pc),a0
  10198.         move.l    a0,RevCompanyDat
  10199.  
  10200.         lea    AuthorString(pc),a0
  10201.         move.l    a0,d1                ; Try to get Author(a4) env
  10202.         lea    Author(pc),a0
  10203.         move.l    a0,d2
  10204.         move.l    #40,d3
  10205.         move.l    #GVF_GLOBAL_ONLY,d4
  10206.         RELLIB    GetVar,_DOSBase
  10207.         tst.l    d0
  10208.         bgt.s    GotAuthor
  10209.         move.l    #DefaultName,RevAuthorDat
  10210.  
  10211. GotAuthor    lea    CompanyString(pc),a0
  10212.         move.l    a0,d1                ; Try to get Company(a4) env
  10213.         lea    Company(pc),a0
  10214.         move.l    a0,d2
  10215.         move.l    #40,d3
  10216.         move.l    #GVF_GLOBAL_ONLY,d4
  10217.         RELLIB    GetVar,_DOSBase
  10218.         tst.l    d0
  10219.         bgt.s    GotCompany
  10220.         move.l    #DefaultName,RevCompanyDat
  10221.  
  10222. GotCompany    cmp.b    #3,LogInputEnd(a4)        ; Only text ???
  10223.         beq.s    .NoNewVerNum
  10224.  
  10225.         moveq    #GD_LogVer,d0            ; Get version number
  10226.         lea    LogGads(a4),a0
  10227.         RELLIB    GetGadgetPtr,_KCXBase
  10228.         move.l    gg_SpecialInfo(a0),a0
  10229.         move.l    si_LongInt(a0),d0
  10230.         move.w    d0,RevRevisionDat
  10231.  
  10232.         move.l    #GD_LogRev,d0            ; Get revision number
  10233.         lea    LogGads(a4),a0
  10234.         DOLIB    GetGadgetPtr
  10235.         move.l    gg_SpecialInfo(a0),a0
  10236.         move.l    si_LongInt(a0),d0
  10237.         move.w    d0,RevRevisionDat+2
  10238.         bra.s    .GotNewVerNum
  10239.  
  10240. .NoNewVerNum    move.w    RevRevisionDat(pc),d0
  10241.         move.w    RevRevisionDat+2(pc),d1
  10242.         subq.w    #1,d1
  10243.         bge.s    .CalcedOldNum
  10244.         moveq    #0,d1
  10245.         subq.w    #1,d0
  10246.         bge.s    .CalcedOldNum
  10247.         moveq    #0,d0
  10248. .CalcedOldNum    move.w    d0,RevRevisionDat
  10249.         move.w    d1,RevRevisionDat+2
  10250.  
  10251. .GotNewVerNum    lea    FileName(pc),a0
  10252.         move.l    a0,d1                ; Open File
  10253.         move.l    #MODE_OLDFILE,d2
  10254.         RELLIB    Open,_DOSBase
  10255.         move.l    d0,InHand(a4)
  10256.         beq    NoRevision
  10257.  
  10258.         lea    TempName(pc),a0
  10259.         move.l    a0,d1
  10260.         move.l    #MODE_NEWFILE,d2        ; Open temporaryfile
  10261.         DOLIB    Open
  10262.         move.l    d0,OutHand(a4)
  10263.         beq    NoRevision
  10264.  
  10265.         tst.b    OnlyLog(a4)            ; Enter new LogMessage ?
  10266.         beq    WriteHeader
  10267.  
  10268.         clr.l    ProgDone(a4)
  10269.         move.l    #(PROGWINWIDTH-92)/13,ProgStep(a4)
  10270.  
  10271.         bsr    ProgMore
  10272.  
  10273. .Loop        bsr    DoFGets
  10274.         ble    NoRevision
  10275.         bsr.s    DoFPuts
  10276.         blt    NoRevision
  10277.         lea    CHeader(pc),a0
  10278.         move.l    ARexxBuffer(a4),a1
  10279.         moveq    #-1,d7
  10280.         bsr    StrCmp
  10281.         tst.l    d0
  10282.         beq.s    GotHeader
  10283.         bra    .Loop
  10284.  
  10285. GotHeader    bsr    ProgMore
  10286.  
  10287.         moveq    #5,d7                ; Skip comming 6 lines
  10288.         cmp.b    #3,LogInputEnd(a4)
  10289.         bne.s    .NotOnlyLog
  10290.         addq.w    #1,d7                ; ... or 7 lines
  10291. .NotOnlyLog    bsr    RSkipLines
  10292.         tst.l    d0
  10293.         beq    NoRevision
  10294.         cmp.b    #3,LogInputEnd(a4)
  10295.         beq.s    .SkipRev
  10296.         bsr.s    DoFGets
  10297.         ble    NoRevision
  10298.         lea    CRevision(pc),a0        ; Convert revision to new string
  10299.         lea    RevRevisionDat(pc),a1
  10300.         bsr    PrintF
  10301.         bsr.s    DoFPuts
  10302.         blt    NoRevision
  10303. .SkipRev    moveq    #3,d7                ; Skip the next 4 lines
  10304.         bsr    RSkipLines
  10305.         tst.l    d0
  10306.         blt    NoRevision
  10307.         bsr    ProgMore
  10308.         bra.s    SkipFPuts
  10309.  
  10310. DoFPutsC    move.l    #CHeader,d2
  10311.         bra.s    DoFPuts0
  10312. DoFPutsNL    move.l    #CLineNL,d2
  10313.         bra.s    DoFPuts0
  10314. DoFPuts        move.l    ARexxBuffer(a4),d2
  10315. DoFPuts0    move.l    OutHand(a4),d1
  10316.         DOLIB    FPuts
  10317.         tst.l    d0
  10318.         rts
  10319. DoFGets        move.l    InHand(a4),d1
  10320.         move.l    ARexxBuffer(a4),d2
  10321.         move.l    #AREXXBUFFSIZE,d3
  10322.         DOLIB    FGets
  10323.         tst.l    d0
  10324.         rts
  10325. SkipFPuts
  10326. .Loop        bsr.s    DoFGets
  10327.         ble    NoRevision
  10328.         move.l    ARexxBuffer(a4),a0
  10329.         bsr    StrLen
  10330.         cmp.l    #3,d0
  10331.         beq.s    .GotIt
  10332.         bsr.s    DoFPuts
  10333.         blt    NoRevision
  10334.         bra    .Loop
  10335. .GotIt        bsr    ProgMore
  10336.         cmp.b    #3,LogInputEnd(a4)        ; Add complete entry ???
  10337.         bne    .StoreCompLog
  10338.         bsr    DoFPuts
  10339.         blt    NoRevision
  10340.         moveq    #2,d7                ; Skip old header
  10341.         bsr    RSkipLines
  10342.         tst.l    d0
  10343.         blt    NoRevision
  10344.         link    a5,#-128            ; Get next line, to see, whether there already
  10345.         lea    -128(a5),a0
  10346.         move.l    InHand(a4),d1            ; Check next line if it`s an extended message
  10347.         move.l    a0,d2
  10348.         DOLIB    FGets
  10349.         tst.l    d0
  10350.         bgt.s    .Ok1
  10351.         unlk    a5
  10352.         bra    NoRevision
  10353. .Ok1        lea    -128(a5),a0            ; Reposition file pointer
  10354.         bsr    StrLen
  10355.         move.l    InHand(a4),d1
  10356.         move.l    d0,d2
  10357.         neg.l    d2
  10358.         move.l    #OFFSET_CURRENT,d3
  10359.         DOLIB    Seek
  10360.         lea    -128(a5),a0            ; Check read line for extension
  10361.         moveq    #0,d7
  10362.         cmp.b    #'-',4(a0)
  10363.         bne.s    .DoCopy
  10364.         cmp.b    #'*',5(a0)
  10365.         bne.s    .DoCopy
  10366.         cmp.b    #'-',6(a0)
  10367.         beq.s    .NoCopy
  10368. .DoCopy        move.l    ARexxBuffer(a4),a0
  10369.         lea    -128(a5),a1            ; Copy header
  10370.         moveq    #1,d7
  10371.         bsr    StrCpy
  10372.         lea    -(128-2)(a5),a1
  10373.         move.b    #' ',(a1)+
  10374.         move.b    #' ',(a1)+
  10375.         move.b    #'-',(a1)+
  10376.         move.b    #'*',(a1)+
  10377.         move.b    #'-',(a1)+
  10378.         move.b    #' ',(a1)+
  10379.         move.b    #' ',(a1)+
  10380.         move.l    ARexxBuffer(a4),a0
  10381.         addq.l    #3,a0
  10382.         bsr    StrCpy
  10383.         moveq    #1,d7
  10384. .NoCopy        lea    CNewLog(pc),a0            ; Write changed log-header
  10385.         lea    RevCreatedOnDat(pc),a1
  10386.         bsr    PrintF
  10387.         bsr    DoFPuts
  10388.         blt    NoRevision
  10389.         lea    NewMsg(a4),a3            ; First insert new message
  10390.         move.l    d7,-(sp)
  10391.         bsr    RWriteMessage
  10392.         move.l    (sp)+,d7
  10393.         tst.l    d0
  10394.         blt    NoRevision
  10395.         tst.b    d7
  10396.         beq.s    .Ok2
  10397.         move.l    OutHand(a4),d1            ; Insert old header
  10398.         lea    -128(a5),a0
  10399.         move.l    a0,d2
  10400.         DOLIB    FPuts
  10401.         tst.l    d0
  10402.         bge.s    .Ok2
  10403.         unlk    a5
  10404.         bra    NoRevision
  10405. .Ok2        unlk    a5
  10406. .FindLogEnd    bsr    DoFGets                ; Insert old Logmessage
  10407.         ble    NoRevision
  10408.         move.l    ARexxBuffer(a4),a0
  10409.         bsr    StrLen
  10410.         cmp.l    #3,d0
  10411.         beq.s    .GotLogEnd
  10412.         bsr    DoFPuts
  10413.         blt    NoRevision
  10414.         bra.s    .FindLogEnd
  10415. .GotLogEnd    bsr    DoFPutsNL
  10416.         blt    NoRevision
  10417.         bsr    ProgMore
  10418.         bra.s    .LoopHeader
  10419. .StoreCompLog    lea    CLog(pc),a0            ; generate new log entry
  10420.         lea    RevRevisionDat(pc),a1
  10421.         bsr    PrintF
  10422.         bsr    DoFPuts
  10423.         blt    NoRevision
  10424.         lea    NewMsg(a4),a3
  10425.         bsr    RWriteMessage            ; Write new logmessage
  10426.         tst.l    d0
  10427.         blt    NoRevision
  10428.         bsr    DoFPutsNL
  10429.         blt    NoRevision
  10430.         bsr    ProgMore
  10431. .LoopHeader    bsr    DoFGets
  10432.         ble    NoRevision
  10433.         bsr    DoFPuts
  10434.         blt    NoRevision
  10435.         lea    CEnd(pc),a0
  10436.         move.l    ARexxBuffer(a4),a1
  10437.         moveq    #-1,d7
  10438.         bsr    StrCmp
  10439.         tst.l    d0
  10440.         beq.s    GotHeaderEnd
  10441.         bra    .LoopHeader
  10442.  
  10443. GotHeaderEnd    bsr    ProgMore
  10444.         bsr    DoFGets
  10445.         ble    NoRevision
  10446.         move.l    ARexxBuffer(a4),a0
  10447.         bsr    StrLen
  10448.         move.l    InHand(a4),d1            ; Reset filepointer to last read
  10449.         move.l    d0,d2                ; position
  10450.         neg.l    d2
  10451.         move.l    #OFFSET_CURRENT,d3
  10452.         DOLIB    Seek
  10453.         move.l    ARexxBuffer(a4),a0        ; Did we read in a define ?
  10454.         move.l    RevDefine(pc),a1
  10455.         move.l    #9,d7
  10456.         bsr    StrCmp                ; Check for the first 9 chars
  10457.         tst.l    d0
  10458.         bne    WriteRest            ; Nope -> go on
  10459.  
  10460.         move.w    RevRevisionDat(pc),d0
  10461.         move.w    RevRevisionDat+2(pc),d1
  10462.         move.w    d0,RevDefineDat
  10463.         move.w    d1,RevDefineDat+2
  10464.         move.w    d0,RevVersionDat
  10465.         move.w    d1,RevVersionDat+2
  10466.         move.l    RevDefine(pc),a0        ; Write new define
  10467.         lea    RevDefineDat(pc),a1
  10468.         bsr    PrintF
  10469.         bsr    DoFPuts
  10470.         blt    NoRevision
  10471.         moveq    #5,d7                ; Skip C lines
  10472.         cmp.l    #AsmRevDefine1,RevDefine    ; Revise Asm source
  10473.         bne.s    NoAsmSkip
  10474.         add.l    #8,d7                ; skip one more line
  10475.         bra.s    DoSkip
  10476. NoAsmSkip    cmp.l    #PASRevDefine1,RevDefine
  10477.         bne.s    DoSkip
  10478.         addq.l    #1,d7
  10479. DoSkip        bsr    DoFGets
  10480.         ble    NoRevision
  10481.         dbf    d7,DoSkip
  10482.         bra    WriteRest            ; Append rest of file
  10483.  
  10484. WriteHeader    clr.l    ProgDone(a4)
  10485.         move.l    #((PROGWINWIDTH-92)/11),ProgStep(a4)
  10486.  
  10487.         bsr    ProgMore
  10488.         bsr    ProgMore
  10489.  
  10490.         bsr    DoFPutsC
  10491.         blt    NoRevision
  10492.         lea    CCopyRight(pc),a0        ; Convert Company(a4) string
  10493.         lea    RevCompanyDat(pc),a1
  10494.         bsr    PrintF
  10495.         bsr    DoFPuts
  10496.         blt    NoRevision
  10497.         bsr    ProgMore
  10498.         lea    CFile(pc),a0            ; convert and write filename
  10499.         lea    RevFileDat(pc),a1
  10500.         bsr    PrintF
  10501.         bsr    DoFPuts
  10502.         blt    NoRevision
  10503.         bsr    ProgMore
  10504.         lea    CCreatedOn(pc),a0        ; do creation date
  10505.         lea    RevCreatedOnDat(pc),a1
  10506.         bsr    PrintF
  10507.         bsr    DoFPuts
  10508.         blt    NoRevision
  10509.         bsr    ProgMore
  10510.         lea    CAuthor(pc),a0            ; do Author(a4)
  10511.         lea    RevAuthorDat(pc),a1
  10512.         bsr    PrintF
  10513.         bsr    DoFPuts
  10514.         blt    NoRevision
  10515.         bsr    ProgMore
  10516.         lea    CRevision(pc),a0        ; Do initial revision
  10517.         lea    RevRevisionDat(pc),a1
  10518.         bsr    PrintF
  10519.         bsr    DoFPuts
  10520.         blt    NoRevision
  10521.         move.l    OutHand(a4),d1            ; Write purpose header
  10522.         move.l    #CPurpose,d2
  10523.         DOLIB    FPuts
  10524.         tst.l    d0
  10525.         blt    NoRevision
  10526.         bsr    ProgMore
  10527.         lea    NewMsg(a4),a3            ; Write purpose message
  10528.         bsr    RWriteMessage
  10529.         tst.l    d0
  10530.         blt    NoRevision
  10531.         lea    CLogInit(pc),a0
  10532.         lea    RevRevisionDat(pc),a1
  10533.         bsr    PrintF
  10534.         bsr    DoFPuts
  10535.         blt    NoRevision
  10536.         bsr    ProgMore
  10537.         move.w    RevRevisionDat(pc),d0
  10538.         move.w    RevRevisionDat+2(pc),d1
  10539.         move.w    d0,RevDefineDat
  10540.         move.w    d1,RevDefineDat+2
  10541.         move.w    d0,RevVersionDat
  10542.         move.w    d1,RevVersionDat+2
  10543.         move.l    RevDefine(pc),a0        ; Write initial define
  10544.         lea    RevDefineDat(pc),a1
  10545.         bsr    PrintF
  10546.         bsr    DoFPuts
  10547.         blt    NoRevision
  10548.  
  10549. WriteRest    bsr    ProgMore
  10550.         move.l    OutHand(a4),d1            ; Write the remaining part of file
  10551.         DOLIB    Flush
  10552.         move.l    InHand(a4),d1
  10553.         DOLIB    Flush
  10554. .Loop        move.l    InHand(a4),d1            ; Read a maximum of 4096 bytes
  10555.         move.l    ARexxBuffer(a4),d2
  10556.         move.l    #AREXXBUFFSIZE,d3
  10557.         DOLIB    Read
  10558.         tst.l    d0
  10559.         beq.s    RestWritten            ; End of file -> go on
  10560.         blt    NoRevision            ; Error -> quit
  10561.         move.l    d0,d3
  10562.         move.l    OutHand(a4),d1            ; Write buffer to temp file
  10563.         move.l    ARexxBuffer(a4),d2
  10564.         DOLIB    Write
  10565.         tst.l    d0
  10566.         ble    NoRevision
  10567.         bra    .Loop
  10568.  
  10569. RestWritten    bsr    ProgMore
  10570.  
  10571.         move.l    OutHand(a4),d1            ; Close files
  10572.         RELLIB    Close,_DOSBase
  10573.         move.l    InHand(a4),d1
  10574.         DOLIB    Close
  10575.  
  10576.         clr.l    OutHand(a4)
  10577.         clr.l    InHand(a4)
  10578.  
  10579.         lea    FileName(pc),a0
  10580.         move.l    a0,d1                ; Copy file back
  10581.         move.l    #MODE_NEWFILE,d2
  10582.         DOLIB    Open
  10583.         move.l    d0,InHand(a4)
  10584.         beq.s    NoRevision
  10585.  
  10586.         lea    TempName(pc),a0
  10587.         move.l    a0,d1
  10588.         move.l    #MODE_OLDFILE,d2
  10589.         DOLIB    Open
  10590.         move.l    d0,OutHand(a4)
  10591.         beq.s    NoRevision
  10592.  
  10593.         bsr    ProgMore
  10594.  
  10595. .Loop        move.l    OutHand(a4),d1            ; Read in 4096 bytes
  10596.         move.l    ARexxBuffer(a4),d2
  10597.         move.l    #AREXXBUFFSIZE,d3
  10598.         DOLIB    Read
  10599.         tst.l    d0                ; 0 read -> end it
  10600.         beq.s    .EndWrite
  10601.         blt.s    NoRevision
  10602.         move.l    d0,d3                ; Store read bytes to new file
  10603.         move.l    InHand(a4),d1
  10604.         move.l    ARexxBuffer(a4),d2
  10605.         DOLIB    Write
  10606.         tst.l    d0
  10607.         blt.s    NoRevision
  10608.         bra    .Loop
  10609.  
  10610. .EndWrite    bsr    ProgMore
  10611.         bra.s    NoErrorFound
  10612.  
  10613. NoRevision    RELLIB    IoErr,_DOSBase            ; Get error number
  10614.         tst.l    d0
  10615.         beq.s    NoErrorFound
  10616.         move.l    d0,ErrorBack(a4)
  10617.         bsr    DisplayError            ; Display error
  10618.  
  10619.         moveq    #0,d7
  10620.         bra.s    GotError
  10621. NoErrorFound    moveq    #1,d7
  10622. GotError    lea    TempName(pc),a0
  10623.         move.l    a0,d1                ; Delete file, if possible
  10624.         RELLIB    DeleteFile,_DOSBase
  10625.         tst.l    OutHand(a4)            ; Close files
  10626.         beq.s    NoTempFile
  10627.         move.l    OutHand(a4),d1
  10628.         DOLIB    Close
  10629.         lea    TempName(pc),a0
  10630.         move.l    a0,d1                ; Delete file, if possible
  10631.         DOLIB    DeleteFile
  10632. NoTempFile    tst.l    InHand(a4)            ; Close input handle
  10633.         beq.s    NoLogWin
  10634.         move.l    InHand(a4),d1
  10635.         DOLIB    Close
  10636.  
  10637. NoLogWin    tst.l    OurLock(a4)
  10638.         beq.s    .NoLock
  10639.         move.l    PastLock(a4),d1
  10640.         RELLIB    CurrentDir,_DOSBase
  10641.         move.l    OurLock(a4),d1
  10642.         DOLIB    UnLock
  10643. .NoLock        clr.l    InHand(a4)
  10644.         clr.l    OutHand(a4)
  10645.  
  10646.         lea    ProgHandle(a4),a3
  10647.         bsr    CloseNormWindow
  10648.  
  10649.         lea    LogHandle(a4),a3
  10650.         bsr    CloseNormWindow            ; Close our window (AGAIN ???)
  10651.  
  10652.         move.l    ARexxAction(a4),d1
  10653.         and.l    #RXFF_RESULT,d1
  10654.         beq.s    .End
  10655.         cmp.b    #2,LogInputEnd(a4)
  10656.         bne.s    .NoCancel
  10657.         lea    FalseStr(pc),a0            ; Create BOOL for error
  10658.         bsr    StrLen
  10659.         RELLIB    CreateArgstring,_RexxSysBase
  10660.         tst.l    d0
  10661.         beq.s    .End
  10662.         move.l    d0,AResult2(a4)
  10663.         bra.s    .End
  10664. .NoCancel    lea    TrueStr(pc),a0            ; Create BOOL for ok
  10665.         bsr    StrLen
  10666.         RELLIB    CreateArgstring,_RexxSysBase
  10667.         tst.l    d0
  10668.         beq.s    .End
  10669.         move.l    d0,AResult2(a4)
  10670.  
  10671. .End        move.l    d7,d0
  10672.         rts
  10673. RevDays        dc.l    .Txt1,.Txt2,.Txt3,.Txt4,.Txt5,.Txt6,.Txt7
  10674. .Txt1        dc.b    "Sunday",0
  10675. .Txt2        dc.b    "Monday",0
  10676. .Txt3        dc.b    "Tuesday",0
  10677. .Txt4        dc.b    "Wednesday",0
  10678. .Txt5        dc.b    "Thursday",0
  10679. .Txt6        dc.b    "Friday",0
  10680. .Txt7        dc.b    "Saturday",0
  10681. TempName    dc.b    "T:KCX.TEMPFILE",0
  10682. AuthorString    dc.b    "AUTHOR",0
  10683. CompanyString    dc.b    "COMPANY",0
  10684.         EVEN
  10685.  
  10686.  
  10687. **********************************************************************
  10688. *             Increase process indicator by given amount             *
  10689. **********************************************************************
  10690. ProgMore    movem.l    RegsAll,-(sp)            ; Set draw-pen first
  10691.         move.l    ProgRPort(a4),a1
  10692.         moveq    #3,d0
  10693.         RELLIB    SetAPen,_GfxBase
  10694.  
  10695.         move.l    ProgDone(a4),d2            ; Get old ratio
  10696.         add.l    ProgStep(a4),d2            ; Calc new one
  10697.         cmp.l    #219,d2                ; Keep gauge within bounds
  10698.         ble.s    .NoRemake
  10699.         move.l    #219,d2
  10700. .NoRemake    move.l    d2,ProgDone(a4)
  10701.  
  10702.         link    a5,#-(4+4+2+2+2+2)
  10703.  
  10704.         lea    ProgTxt(a4),a0
  10705.         move.l    a0,FontPtr(a5)
  10706.         move.l    d2,-(sp)
  10707.         move.l    ProgHandle(a4),a0
  10708.         move.l    wd_WScreen(a0),-4(a5)
  10709.         moveq    #0,d2
  10710.         moveq    #0,d3
  10711.         move.w    ProgWinWidth(a4),d2
  10712.         move.w    ProgWinHeight(a4),d3
  10713.         RELLIB    ComputeFont,_KCXBase
  10714.         move.l    (sp)+,d2
  10715.  
  10716.         move.l    #5,d0
  10717.         DOLIB    ComputeY
  10718.         add.w    OffY(a5),d0
  10719.         move.l    d0,d1
  10720.         move.l    d2,d0
  10721.         DOLIB    ComputeX
  10722.         move.l    d0,d2
  10723.         moveq    #14,d0
  10724.         DOLIB    ComputeY
  10725.         move.l    d0,d3
  10726.         moveq    #40,d0
  10727.         DOLIB    ComputeX
  10728.         add.w    OffX(a5),d0
  10729.         move.l    ProgRPort(a4),a1
  10730.         add.l    d0,d2
  10731.         add.l    d1,d3
  10732.         RELLIB    RectFill,_GfxBase
  10733.  
  10734.         unlk    a5
  10735.         movem.l    (sp)+,RegsAll
  10736.         rts
  10737.  
  10738.  
  10739.  
  10740. **********************************************************************
  10741. *           Checks for inputs from Purpose/Log msg window            *
  10742. **********************************************************************
  10743. CheckRevInput    clr.b    LogInputEnd(a4)            ; Set end flag for quit
  10744. LoopLog        tst.b    LogInputEnd(a4)            ; Are we to quit
  10745.         bne    LogInputOver
  10746.         move.l    LogHandle(a4),a0        ; Wait for a message
  10747.         move.l    wd_UserPort(a0),a0
  10748.         CALLSYS    WaitPort
  10749. LoopLogMsg    move.l    LogHandle(a4),a0        ; get it
  10750.         move.l    wd_UserPort(a0),a0
  10751.         RELLIB    GT_GetIMsg,_GadToolsBase
  10752.         tst.l    d0
  10753.         beq.s    LoopLog
  10754.         move.l    d0,a1
  10755.         move.l    im_Class(a1),d6
  10756.         move.l    d6,d0
  10757.         and.l    #(IDCMP_GADGETUP|IDCMP_GADGETDOWN),d0
  10758.         beq.s    .NoGad
  10759.         move.l    im_IAddress(a1),a3
  10760.         move.w    gg_GadgetID(a3),d7
  10761. .NoGad        moveq    #0,d0
  10762.         move.w    im_Code(a1),d0
  10763.         bsr    GetUpperCase
  10764.         move.l    d0,d5
  10765.         DOLIB    GT_ReplyIMsg
  10766.  
  10767.         cmp.l    #IDCMP_VANILLAKEY,d6
  10768.         bne.s    .NoVKey
  10769.         cmp.b    #ESCKEY,d5
  10770.         beq    LogCancelKey
  10771.         lea    LogGads(a4),a3
  10772.         moveq    #0,d1
  10773. .FindGad    move.l    (a3),d0
  10774.         beq.s    .NoVKey
  10775.         move.l    d0,a0
  10776.         move.l    gg_UserData(a0),d0
  10777.         cmp.b    d0,d5
  10778.         bne.s    .NextGad
  10779.         move.l    #IDCMP_GADGETUP,d6
  10780.         moveq    #-1,d5
  10781.         move.l    d1,d7
  10782.         bra.s    .NoVKey
  10783. .NextGad    addq.l    #4,a3
  10784.         addq.l    #1,d1
  10785.         bra.s    .FindGad
  10786.  
  10787. .NoVKey        cmp.l    #IDCMP_ACTIVEWINDOW,d6        ; Window activated ?
  10788.         bne.s    LogWinInAct
  10789.  
  10790.         moveq    #GD_Line1,d0
  10791.         lea    LogGads(a4),a0
  10792.         move.l    LogHandle(a4),a1
  10793.         RELLIB    ActStringGad,_KCXBase
  10794.         bra    LoopLogMsg
  10795.  
  10796. LogWinInAct    cmp.l    #IDCMP_GADGETUP,d6        ; Gadget released
  10797.         bne    LogNoGadUp
  10798.  
  10799.         cmp.w    #GD_LogVer,d7
  10800.         bne.s    NoLogVerGad
  10801.         tst.l    d5
  10802.         bge    LoopLogMsg
  10803.         move.l    #GD_LogVer,d0
  10804.         lea    LogGads(a4),a0
  10805.         move.l    LogHandle(a4),a1
  10806.         RELLIB    ActStringGad,_KCXBase
  10807.         bra    LoopLogMsg
  10808.  
  10809. NoLogVerGad    cmp.w    #GD_LogOnlyText,d7        ; Only add text ???
  10810.         bne.s    LogNoText
  10811.         tst.l    d5
  10812.         bge.s    .NoKey
  10813.         tst.b    OnlyLog(a4)
  10814.         beq    LoopLogMsg
  10815.         move.l    d7,d0
  10816.         lea    LogGads(a4),a0
  10817.         move.l    LogHandle(a4),a5
  10818.         bsr    ButtonCheck
  10819. .NoKey        move.b    #3,LogInputEnd(a4)
  10820.         bra    LoopLogMsg
  10821.  
  10822. LogNoText    cmp.w    #GD_LogOk,d7            ; Ok gadget ?
  10823.         bne.s    LogNoOk
  10824.         tst.l    d5
  10825.         bge.s    .NoKey
  10826.         move.l    d7,d0
  10827.         lea    LogGads(a4),a0
  10828.         move.l    LogHandle(a4),a5
  10829.         bsr    ButtonCheck
  10830. .NoKey        move.b    #1,LogInputEnd(a4)        ; Yep -> quit input
  10831.         bra    LoopLogMsg
  10832.  
  10833. LogNoOk        cmp.w    #GD_LogCancel,d7        ; Cancel gadget ?
  10834.         bne    LoopLogMsg
  10835.         tst.l    d5
  10836.         bge.s    NoLogCanKey
  10837. LogCancelKey    move.l    #GD_LogCancel,d0
  10838.         lea    LogGads(a4),a0
  10839.         move.l    LogHandle(a4),a5
  10840.         bsr    ButtonCheck
  10841. NoLogCanKey    move.b    #2,LogInputEnd(a4)
  10842.         bra    LoopLogMsg
  10843.  
  10844. LogNoGadUp    cmp.l    #IDCMP_CHANGEWINDOW,d6        ; Window moved ?
  10845.         bne    LoopLogMsg
  10846.         move.l    LogHandle(a4),a0        ; Store new position
  10847.         lea    LogWinLeft(a4),a1
  10848.         bsr    StoreWinPos
  10849.         bra    LoopLogMsg
  10850. LogInputOver    rts
  10851.  
  10852.  
  10853.  
  10854.  
  10855. **********************************************************************
  10856. *                    Checks for existing revision                    *
  10857. **********************************************************************
  10858. CheckRevision    move.w    #1,RevRevisionDat
  10859.         clr.w    RevRevisionDat+2
  10860.         lea    FileName(pc),a0
  10861.         move.l    a0,d1                ; Try to open file
  10862.         move.l    #MODE_OLDFILE,d2
  10863.         RELLIB    Open,_DOSBase
  10864.         move.l    d0,InHand(a4)
  10865.         beq    FileNotFound
  10866.  
  10867.         moveq    #14,d6
  10868. CheckLines    bsr    DoFGets
  10869.         beq.s    FileError
  10870.         blt    FileNotFound
  10871.         lea    CHeader(pc),a0
  10872.         move.l    ARexxBuffer(a4),a1
  10873.         moveq    #-1,d7
  10874.         bsr    StrCmp                ; current line our header ?
  10875.         tst.l    d0
  10876.         beq.s    IsMine                ; Yep -> go on
  10877.         dbf    d6,CheckLines            ; Loop
  10878. FileError    moveq    #0,d7                ; Nothing found
  10879.         bra.s    EndCheckRev
  10880. IsMine        moveq    #7,d6
  10881. .GetRevision    bsr    DoFGets
  10882.         ble    FileError
  10883.         dbf    d6,.GetRevision
  10884.         link    a5,#-4
  10885.         move.l    ARexxBuffer(a4),a0
  10886.         lea    23(a0),a0
  10887.         move.l    a0,a2
  10888.         move.l    a0,d1
  10889.         lea    -4(a5),a0
  10890.         move.l    a0,d2
  10891.         RELLIB    StrToLong,_DOSBase
  10892.         move.l    -4(a5),d0
  10893.         move.w    d0,RevRevisionDat
  10894. .FindRev    cmp.b    #'.',(a2)+
  10895.         bne.s    .FindRev
  10896.         move.l    a2,d1
  10897.         lea    -4(a5),a0
  10898.         move.l    a0,d2
  10899.         DOLIB    StrToLong
  10900.         move.l    -4(a5),d0
  10901.         move.w    d0,RevRevisionDat+2
  10902.         unlk    a5
  10903.         move.w    RevRevisionDat(pc),d0
  10904.         move.w    RevRevisionDat+2(pc),d1
  10905.         addq.w    #1,d1
  10906.         cmp.w    #100,d1
  10907.         blt.s    .GoOn
  10908.         addq.w    #1,d0
  10909.         moveq    #0,d1
  10910. .GoOn        move.w    d0,RevRevisionDat
  10911.         move.w    d1,RevRevisionDat+2
  10912.         moveq    #1,d7                ; Got it
  10913.         bra.s    EndCheckRev
  10914. FileNotFound    moveq    #-1,d7
  10915. EndCheckRev    move.b    d7,OnlyLog(a4)            ; store flag
  10916.         tst.l    InHand(a4)            ; Close file again
  10917.         beq.s    .End
  10918.         move.l    InHand(a4),d1
  10919.         DOLIB    Close
  10920.         clr.l    InHand(a4)
  10921. .End        rts
  10922.  
  10923.  
  10924.  
  10925.  
  10926. **********************************************************************
  10927. *                      Skip the following bytes                      *
  10928. **********************************************************************
  10929. RSkipLines    bsr    DoFGets
  10930.         ble.s    .Error
  10931.         bsr    DoFPuts
  10932.         blt.s    .Error
  10933.         dbf    d7,RSkipLines            ; Loop
  10934.         bsr    ProgMore
  10935.         moveq    #1,d0
  10936.         rts
  10937. .Error        moveq    #0,d0
  10938.         rts
  10939.  
  10940.  
  10941.  
  10942.  
  10943.  
  10944. **********************************************************************
  10945. *                 Writes Log/Purpose message to file                 *
  10946. **********************************************************************
  10947. RWriteMessage    link    a5,#-8
  10948.         lea    CLine(pc),a0
  10949.         lea    -8(a5),a1
  10950.         bsr    StrCpy
  10951.         move.b    #'-',-3(a5)
  10952.         moveq    #4,d7                ; Now loop for message lines
  10953. .LoopPurp    tst.b    (a3)                ; line ok ?
  10954.         beq.s    .EndPurp
  10955.         move.l    OutHand(a4),d1            ; Write initial chars
  10956.         cmp.b    #4,d7
  10957.         bne.s    .NormalLine
  10958.         lea    -8(a5),a0
  10959.         bra.s    .WriteLine
  10960. .NormalLine    lea    CLine(pc),a0
  10961. .WriteLine    move.l    a0,d2
  10962.         DOLIB    FPuts
  10963.         tst.l    d0
  10964.         blt.s    .Error
  10965.         move.l    a3,a0
  10966.         bsr    StrLen
  10967.         move.b    #$0a,0(a0,d0)
  10968.         move.l    OutHand(a4),d1
  10969.         move.l    a3,d2
  10970.         DOLIB    FPuts
  10971.         tst.l    d0
  10972.         blt.s    .Error
  10973. .EndPurp    lea    62(a3),a3            ; Loop
  10974.         dbf    d7,.LoopPurp
  10975.         bsr    ProgMore
  10976. .Error        unlk    a5
  10977.         rts
  10978.  
  10979.  
  10980.  
  10981.  
  10982. **********************************************************************
  10983. *              Copy message eneterd to desired location              *
  10984. **********************************************************************
  10985. CopyMessage    lea    LogGads(a4),a2            ; Copy contents of string gads
  10986.         move.l    (a2),a2
  10987.         moveq    #4,d7                ; Loop for 5 gadgets
  10988. .Loop        move.l    gg_SpecialInfo(a2),a0
  10989.         move.l    si_Buffer(a0),a0
  10990.         move.l    a3,a1
  10991.         bsr    StrCpy                ; Copy string to buffer
  10992.         move.l    gg_NextGadget(a2),a2
  10993.         lea    62(a3),a3            ; Next buffer
  10994.         dbf    d7,.Loop
  10995.         rts
  10996.  
  10997.  
  10998.  
  10999.  
  11000. **********************************************************************
  11001. *                 Deletes our environment variables                  *
  11002. **********************************************************************
  11003. DeleteEnvs    tst.l    _DOSBase(a4)
  11004.         beq.s    .End
  11005.         lea    EnvDayString(pc),a1
  11006.         move.l    a1,d1
  11007.         move.l    #GVF_GLOBAL_ONLY,d2
  11008.         RELLIB    DeleteVar,_DOSBase
  11009.         lea    EnvDateString(pc),a1
  11010.         move.l    a1,d1
  11011.         move.l    #GVF_GLOBAL_ONLY,d2
  11012.         DOLIB    DeleteVar
  11013.         lea    EnvTimeString(pc),a1
  11014.         move.l    a1,d1
  11015.         move.l    #GVF_GLOBAL_ONLY,d2
  11016.         DOLIB    DeleteVar
  11017. .End        rts
  11018.  
  11019.  
  11020.  
  11021.  
  11022.  
  11023. **********************************************************************
  11024. *           Display Msg that only to be run under Kick2.x            *
  11025. **********************************************************************
  11026. OnlyKick20    sub.l    a1,a1
  11027.         CALLSYS    FindTask
  11028.         move.l    d0,a0
  11029.         tst.l    pr_CLI(a0)
  11030.         beq.s    .FromWB
  11031.         lea    DosName,a1
  11032.         moveq    #0,d0
  11033.         DOLIB    OpenLibrary
  11034.         move.l    d0,a6
  11035.         DOLIB    Output
  11036.         move.l    d0,d1
  11037.         move.l    #Only20Txt,d2
  11038.         move.l    #Only20TxtEnd-Only20Txt,d3
  11039.         DOLIB    Write
  11040.         move.l    a6,a1
  11041.         CALLSYS    CloseLibrary
  11042.         rts
  11043. .FromWB        lea    IntName,a1            ; try to open IntBase
  11044.         moveq    #0,d0
  11045.         CALLSYS    OpenLibrary
  11046.         tst.l    d0
  11047.         beq.s    OnlyKick20Ret
  11048.         move.l    d0,a6
  11049.  
  11050.         sub.l    a0,a0                ; Display requester
  11051.         lea    Only20ITxt(pc),a1
  11052.         lea    OkITxt(pc),a2
  11053.         move.l    a2,a3
  11054.         moveq    #0,d0
  11055.         moveq    #0,d1
  11056.         move.l    #300,d2
  11057.         moveq    #60,d3
  11058.         DOLIB    AutoRequest
  11059.  
  11060.         move.l    a6,a1
  11061.         CALLSYS    CloseLibrary
  11062. OnlyKick20Ret    rts
  11063.  
  11064.  
  11065.  
  11066. **********************************************************************
  11067. *                          Display an error                          *
  11068. **********************************************************************
  11069. DisplayError    tst.l    ErrorBack(a4)
  11070.         bge.s    .GoOn
  11071.         rts
  11072. .GoOn        tst.l    _KCXBase(a4)
  11073.         beq.s    .End
  11074.         movem.l    RegsAll,-(sp)
  11075.         move.l    ErrorBack(a4),d0        ; Get error num
  11076.         cmp.l    #BROKER_ERR,d0            ; Is it the broker set up error ?
  11077.         bne.s    NoDoubleMean            ; Nope -> go on
  11078.         tst.l    DoublePort(a4)            ; Did we already had a port ?
  11079.         beq.s    NoDoubleMean            ; Nope -> go on
  11080.         movem.l    (sp)+,RegsAll
  11081. .End        rts
  11082. NoDoubleMean    move.l    ErrorBack(a4),d0
  11083.         lea    BackErrArg(a4),a3
  11084.         RELLIB    DisplayError,_KCXBase
  11085.         movem.l    (sp)+,RegsAll
  11086.         rts
  11087.  
  11088.  
  11089.  
  11090. **********************************************************************
  11091. *                  Just skip the blanks in a string                  *
  11092. **********************************************************************
  11093. SkipBlanks    cmp.b    #' ',(a0)            ; Loop while there are spaces
  11094.         beq.s    .NoEnd                ; and tabs
  11095.         cmp.b    #$09,(a0)
  11096.         beq.s    .NoEnd
  11097.         cmp.b    #'"',(a0)
  11098.         beq.s    .NoEnd
  11099.         cmp.b    #"'",(a0)
  11100.         beq.s    .NoEnd
  11101.         tst.b    (a0)
  11102.         beq.s    .GotEnd
  11103.         bra.s    .GotEnd
  11104. .NoEnd        addq.l    #1,a0
  11105.         bra.s    SkipBlanks
  11106. .GotEnd        rts
  11107.  
  11108.  
  11109.  
  11110. **********************************************************************
  11111. *                           Just a printf                            *
  11112. **********************************************************************
  11113. PrintF        movem.l    RegsAll,-(sp)
  11114.         lea    PutChProc(pc),a2
  11115.         move.l    ARexxBuffer(a4),a3
  11116.         CALLSYS    RawDoFmt
  11117.         movem.l    (sp)+,RegsAll
  11118.         rts
  11119.  
  11120.  
  11121. **********************************************************************
  11122. *                      Small dummy for RawDoFmt                      *
  11123. **********************************************************************
  11124. PutChProc    move.b    d0,(a3)+
  11125.         rts
  11126.  
  11127.  
  11128. **********************************************************************
  11129. *                         Enable the broker                          *
  11130. **********************************************************************
  11131. EnableBroker    movem.l    RegsAll,-(sp)
  11132.         tst.b    Disabled(a4)            ; Don`t enable when disabled
  11133.         bne.s    .End
  11134.         move.l    MyBroker(a4),a0
  11135.         moveq    #1,d0
  11136.         LNKLIB    ActivateCxObj,_CxBase
  11137. .End        movem.l    (sp)+,RegsAll
  11138.         rts
  11139.  
  11140.  
  11141.  
  11142. **********************************************************************
  11143. *                        Disable broker again                        *
  11144. **********************************************************************
  11145. DisableBroker    movem.l    RegsAll,-(sp)
  11146.         tst.b    Disabled(a4)
  11147.         bne.s    .End
  11148.         move.l    MyBroker(a4),a0
  11149.         moveq    #0,d0
  11150.         LNKLIB    ActivateCxObj,_CxBase
  11151.         CALLSYS    Forbid
  11152.         bsr    OnScreen
  11153.         CALLSYS    Permit
  11154.         bsr    OnMouse
  11155. .End        movem.l    (sp)+,RegsAll
  11156.         rts
  11157.  
  11158.  
  11159.  
  11160. **********************************************************************
  11161. *                        Display the AppIcon                         *
  11162. **********************************************************************
  11163. OnAppIcon    tst.l    KCXAppIcon(a4)
  11164.         bne.s    .End
  11165.         lea    MyAppIconText,a0        ; Display AppIcon
  11166.         move.l    AppPort(a4),a1
  11167.         sub.l    a2,a2
  11168.         lea    KCXAppIconDef,a3
  11169.         move.l    a4,-(sp)
  11170.         move.l    _WorkBenchBase(a4),a6
  11171.         sub.l    a4,a4
  11172.         DOLIB    AddAppIconA
  11173.         move.l    (sp)+,a4
  11174.         move.l    d0,KCXAppIcon(a4)
  11175.         bne.s    .End
  11176. .Error        move.l    #APPICON_ERR,ErrorBack(a4)
  11177.         bsr    DisplayError
  11178.         clr.b    DispAppIcon(a4)
  11179. .End        rts
  11180.  
  11181.  
  11182.  
  11183.  
  11184.  
  11185.  
  11186. **********************************************************************
  11187. *                 Remove the AppIcon from WorkBench                  *
  11188. **********************************************************************
  11189. OffAppIcon    tst.l    KCXAppIcon(a4)
  11190.         beq.s    .NoIcon
  11191.         move.l    KCXAppIcon(a4),a0
  11192.         RELLIB    RemoveAppIcon,_WorkBenchBase
  11193.         clr.l    KCXAppIcon(a4)
  11194. .NoIcon        rts
  11195.  
  11196.  
  11197.  
  11198.  
  11199. **********************************************************************
  11200. *           Checks if the inserted disk should be formated           *
  11201. **********************************************************************
  11202. CheckFormat    tst.l    FormHandle(a4)            ; Formatter window open?
  11203.         bne.s    .End                ; Yep -> skip question
  11204.         sub.l    a0,a0                ; PopUp Requester
  11205.         lea    MyEasyRequest(pc),a1
  11206.         move.l    #EasyTitle,es_Title(a1)
  11207.         LOCLEA    DoFormatText,es_TextFormat(a1)
  11208.         LOCLEA    FormatGads,es_GadgetFormat(a1)
  11209.         sub.l    a2,a2
  11210.         move.w    FormatDrive(a4),d0        ; Get number of slot
  11211.         lea    DriveList(a4),a3
  11212.         lsl.w    #2,d0
  11213.         lea    0(a3,d0.w),a3            ; Get address of string
  11214.         RELLIB    EasyRequestArgs,_IntuitionBase
  11215.         cmp.l    #1,d0
  11216.         bne.s    .End
  11217.         bsr    OpenFormWin            ; Yep, handle the formatter
  11218. .End        rts
  11219.  
  11220.  
  11221.  
  11222. **********************************************************************
  11223. *                        Start the formatting                        *
  11224. **********************************************************************
  11225. GoGoGoFormat    lea    MainCom(pc),a0            ; Generate main commandline
  11226.         lea    FormatCommand(a4),a1
  11227.         bsr    StrCpy
  11228.         lea    DriveArg,a0
  11229.         subq.l    #1,a1
  11230.         bsr    StrCpy
  11231.         move.w    FormatDrive(a4),d0
  11232.         lea    DriveList(a4),a0
  11233.         lsl.w    #2,d0
  11234.         move.l    0(a0,d0.w),a0
  11235.         subq.l    #1,a1
  11236.         bsr    StrCpy
  11237.         lea    NameArg,a0
  11238.         subq.l    #1,a1
  11239.         bsr    StrCpy
  11240.         move.b    #'"',-1(a1)
  11241.         lea    FormatDriveName(a4),a0
  11242.         bsr    StrCpy
  11243.         move.b    #'"',-1(a1)
  11244.         addq.l    #1,a1
  11245.         tst.b    MakeIcons(a4)            ; Add switches
  11246.         bne.s    .NoIcons
  11247.         lea    IconsArg,a0
  11248.         subq.l    #1,a1
  11249.         bsr    StrCpy
  11250. .NoIcons    tst.b    QuickFormat(a4)
  11251.         beq.s    .NotQuick
  11252.         lea    QuickArg,a0
  11253.         subq.l    #1,a1
  11254.         bsr    StrCpy
  11255. .NotQuick    tst.b    FFSDrive(a4)
  11256.         beq.s    .NotFFS
  11257.         lea    FFSArg,a0
  11258.         subq.l    #1,a1
  11259.         bsr    StrCpy
  11260. .NotFFS        tst.b    NoVerify(a4)
  11261.         beq.s    .NoVerify
  11262.         lea    VerifyArg,a0
  11263.         subq.l    #1,a1
  11264.         bsr    StrCpy
  11265. .NoVerify    tst.b    Install(a4)
  11266.         beq.s    .NoInstall
  11267.         lea    InstallArg,a0
  11268.         subq.l    #1,a1
  11269.         bsr    StrCpy
  11270. .NoInstall    tst.b    EjectDrive(a4)
  11271.         beq.s    .NoEject
  11272.         lea    EjectArg,a0
  11273.         subq.l    #1,a1
  11274.         bsr    StrCpy
  11275. .NoEject    tst.b    DirCache(a4)
  11276.         beq.s    .NoCacheMode
  11277.         lea    IntModeArg(pc),a0
  11278.         subq.l    #1,a1
  11279.         bsr    StrCpy
  11280.         lea    DirCacheArg(pc),a0
  11281.         subq.l    #1,a1
  11282.         bsr    StrCpy
  11283.         bra.s    .GotCache
  11284. .NoCacheMode    tst.b    InterMode(a4)
  11285.         beq.s    .GotCache
  11286.         lea    IntModeArg(pc),a0
  11287.         subq.l    #1,a1
  11288.         bsr    StrCpy
  11289. .GotCache    LOCLEA    FormatWin,a0            ; Open new outhandle
  11290.         move.l    a0,d1
  11291.         move.l    #MODE_NEWFILE,d2
  11292.         RELLIB    Open,_DOSBase
  11293.         move.l    d0,FormatIn
  11294.         tst.l    d0
  11295.         beq.s    .End
  11296.         move.l    d0,a0
  11297.         add.l    a0,a0
  11298.         add.l    a0,a0
  11299.         move.l    fh_Type(a0),FormConTask        ; Get pointer to console task
  11300.         lea    FormatTags(pc),a0        ; Start process
  11301.         move.l    a0,d1
  11302.         DOLIB    CreateNewProc
  11303. .End        rts
  11304. FormatTags    dc.l    NP_Entry
  11305.         dc.l    Formatter
  11306.         dc.l    NP_Name
  11307.         dc.l    FormSlave
  11308.         dc.l    NP_ConsoleTask
  11309. FormConTask    dc.l    0
  11310.         dc.l    NP_Input
  11311. FormatIn    dc.l    0
  11312.         dc.l    NP_Output
  11313.         dc.l    0
  11314.         dc.l    NP_Priority
  11315.         dc.l    0
  11316.         dc.l    NP_Cli
  11317.         dc.l    1
  11318.         dc.l    TAG_DONE
  11319. MainCom        dc.b    "SYS:System/Format",0
  11320. FormSlave    dc.b    "KCX Formatter Slave",0
  11321. NewCOSName    dc.b    "*",0
  11322.         EVEN
  11323.  
  11324. **********************************************************************
  11325. *                This is the dummy Formatter process                 *
  11326. **********************************************************************
  11327. Formatter    link    a5,#-8            ; Start the formatter
  11328.         move.l    ZeroBase(pc),a4
  11329.         move.l    $4.w,a6
  11330.         move.l    ThisTask(a6),a3
  11331.         tst.l    pr_COS(a3)        ; Has this proc got an OutHandle
  11332.         bne.s    .End
  11333.         tst.l    pr_ConsoleTask(a3)    ; Console Task ?
  11334.         beq.s    .End
  11335.         move.l    pr_COS(a3),-4(a5)    ; Open new OutHandle and store old OutHandle
  11336.         lea    NewCOSName(pc),a0
  11337.         move.l    a0,d1
  11338.         move.l    #MODE_NEWFILE,d2
  11339.         RELLIB    Open,_DOSBase
  11340.         move.l    d0,-8(a5)
  11341.         move.l    d0,pr_COS(a3)        ; Start command
  11342.         lea    FormatCommand(a4),a0
  11343.         move.l    a0,d1
  11344.         moveq    #0,d2
  11345.         DOLIB    SystemTagList
  11346.         CALLSYS    Forbid
  11347.         tst.l    -8(a5)            ; Restore old OutHandle
  11348.         beq.s    .End
  11349.         move.l    -4(a5),pr_COS(a3)    ; Hand close ours
  11350.         move.l    -8(a5),d1
  11351.         RELLIB    Close,_DOSBase
  11352. .End        unlk    a5
  11353.         rts
  11354.  
  11355.  
  11356.  
  11357.  
  11358.  
  11359.  
  11360. **********************************************************************
  11361. *               Filter double Code/Qualifier occurance               *
  11362. * D0 = Code                                                          *
  11363. * D1 = Qualifier                                                     *
  11364. **********************************************************************
  11365. FilterDouble    cmp.w    #IECODE_LBUTTON,d0        ; If one of the buttons
  11366.         bne.s    .NotLeft            ; is defined within code and qualifier
  11367.         and.w    #~IEQUALIFIER_LEFTBUTTON,d1    ; clear the button out of the qualifier
  11368. .NotLeft    cmp.w    #IECODE_MBUTTON,d0
  11369.         bne.s    .NotMid
  11370.         and.w    #~IEQUALIFIER_MIDBUTTON,d1
  11371. .NotMid        cmp.w    #IECODE_RBUTTON,d0
  11372.         bne.s    .NotRight
  11373.         and.w    #~IEQUALIFIER_RBUTTON,d1
  11374. .NotRight    rts
  11375.  
  11376.  
  11377.  
  11378.  
  11379.  
  11380.  
  11381.  
  11382. **********************************************************************
  11383. *                      New OpenScreen function                       *
  11384. **********************************************************************
  11385. NewOpenScreen    movem.l    d0/a0-a1,-(sp)
  11386.         move.l    ZeroBase(pc),a0
  11387.         tst.b    Disabled(a0)
  11388.         bne.s    .NormalOpen
  11389.         tst.b    TagScreens(a0)
  11390.         beq.s    .NormalOpen
  11391.         movem.l    (sp)+,d0/a0-a1
  11392.         sub.l    a1,a1                ;  "No" tags
  11393.         move.w    ns_Type(a0),d0            ; Get type of screen
  11394.         move.w    d0,d1
  11395.         and.w    #NS_EXTENDED,d1            ; Check for extension
  11396.         beq.s    .DoPatch
  11397.         move.w    d0,d1
  11398.         and.w    #~NS_EXTENDED,d0        ; Remove extension field
  11399.         move.w    d0,ns_Type(a0)
  11400.         move.w    d1,d0                ; Restore original type field
  11401.         move.l    ens_Extension(a0),a1        ; Get extension pointer to TagList
  11402.         clr.l    ens_Extension(a0)        ; Clear extension field
  11403. .DoPatch    movem.l    d0/a0-a1,-(sp)            ; Same type/adr of newscreen/and ptr to TagList
  11404.         bsr.s    DoTaskTagPatch            ; Patch TagList
  11405.         movem.l    (sp)+,d1/a0-a1            ; Reget pointers
  11406.         move.w    d1,ns_Type(a0)            ; Restore old settings
  11407.         and.w    #NS_EXTENDED,d1
  11408.         beq.s    .NoEns
  11409.         move.l    a1,ens_Extension(a0)        ; and Extensionpointer
  11410. .NoEns        rts
  11411. .NormalOpen    movem.l    (sp)+,d0/a0-a1
  11412.         move.l    #OldOpenScreen,d0
  11413.         bra    DoRemember
  11414.  
  11415.  
  11416.  
  11417.  
  11418. **********************************************************************
  11419. *                   New OpenScreenTagList function                   *
  11420. **********************************************************************
  11421. NewOpenScreenTagList
  11422. **********************************************************************
  11423. *              Ask for calling task and patch if needed              *
  11424. **********************************************************************
  11425. DoTaskTagPatch    link    a5,#-768
  11426.         movem.l    d2-d7/a0-a6,-(sp)
  11427.         move.l    ZeroBase(pc),a4
  11428.         sub.l    a3,a3
  11429.         tst.b    Disabled(a4)
  11430.         bne    .NoTagTsks
  11431.         tst.b    TagScreens(a4)
  11432.         beq    .NoTagTsks
  11433.  
  11434.         move.l    28(sp),a1
  11435.         lea    -768(a5),a2            ; Copy taglist
  11436.         clr.l    ti_Tag(a2)
  11437.         move.l    a1,d0
  11438.         beq.s    .TagsCopied
  11439. .CopyTags    move.l    a1,a0
  11440.         moveq    #(ti_SIZEOF/4)-1,d7
  11441. .CopyLoop    move.l    (a0)+,(a2)+
  11442.         dbf    d7,.CopyLoop
  11443.         addq.l    #ti_SIZEOF,a1
  11444.         tst.l    (-ti_SIZEOF+ti_Tag)(a1)
  11445.         bne.s    .CopyTags
  11446.         subq.l    #ti_SIZEOF,a2
  11447.  
  11448. .TagsCopied    sub.l    a1,a1                ; Find calling task
  11449.         CALLSYS    FindTask
  11450.         move.l    d0,a3
  11451.         moveq    #79,d7
  11452.         moveq    #1,d5
  11453.         cmp.b    #NT_PROCESS,LN_TYPE(a3)
  11454.         bne.s    .IsTask
  11455.         moveq    #0,d5
  11456.         tst.l    pr_TaskNum(a3)
  11457.         beq.s    .IsTask
  11458.         move.l    pr_CLI(a3),d0            ; Cli ?
  11459.         beq.s    .IsTask
  11460.         lsl.l    #2,d0
  11461.         move.l    d0,a0
  11462.         tst.l    cli_Module(a0)            ; CLI Module
  11463.         beq.s    .IsTask
  11464.         move.l    cli_CommandName(a0),d0        ; Get CommandName of process
  11465.         lsl.l    #2,d0
  11466.         move.l    d0,a0
  11467.         moveq    #0,d7
  11468.         move.b    (a0)+,d7
  11469.         bra.s    .GoOnName
  11470. .IsTask        move.l    LN_NAME(a3),a0            ; It`s a normal Task
  11471.         lea    TermName(pc),a1
  11472.         bsr    StrCmp
  11473.         tst.l    d0
  11474.         bne.s    .GoOnName
  11475.         sub.l    a3,a3
  11476.         bra    .NoTagTsks
  11477. .GoOnName    lea    -(170+80)(a5),a1
  11478.         bsr    StrNCpy
  11479.  
  11480.         lea    TagScrsTasks(a4),a3
  11481.         TSTLIST    a3
  11482.         beq.s    .NoSpecialTask
  11483.         move.l    LH_HEAD(a3),a3            ; Get address of first entry
  11484. .LoopTasks    move.l    a3,d0
  11485.         beq.s    .NoSpecialTask
  11486.         lea    tagscr_Name(a3),a0        ; Get name
  11487.         moveq    #0,d6
  11488.         cmp.b    #'-',(a0)
  11489.         bne.s    .NoSkipTask
  11490.         moveq    #1,d6
  11491.         addq.l    #1,a0
  11492. .NoSkipTask    tst.b    d5
  11493.         beq.s    .IsProc
  11494.         lea    -(170+80)(a5),a1
  11495.         bsr    StrCmp
  11496.         tst.l    d0
  11497.         beq.s    .GotTask
  11498.         bra.s    .NotSameTask
  11499. .IsProc        move.l    a0,d1
  11500.         lea    -170(a5),a0            ; Get buffer for pattern
  11501.         move.l    a0,d2
  11502.         move.l    #170,d3
  11503.         RELLIB    ParsePatternNoCase,_DOSBase    ; Tokenize pattern
  11504.         lea    -170(a5),a0            ; Check if name of task matches
  11505.         move.l    a0,d1
  11506.         lea    -(170+80)(a5),a0
  11507.         move.l    a0,d2
  11508.         DOLIB    MatchPatternNoCase
  11509.         tst.l    d0
  11510.         bne.s    .GotTask
  11511. .NotSameTask    SUCC    a3,a3
  11512.         bra.s    .LoopTasks
  11513.  
  11514. .GotTask    tst.b    d6                ; Task to be excluded ?
  11515.         bne.s    .NoTagTsks            ; Yep -> no patch
  11516.         bsr    DoTagPatches            ; Patch list
  11517.         tst.b    d0                ; Patches made ?
  11518.         beq.s    .NoTagTsks            ; Nope -> normal openup
  11519.         bra.s    .DonePatches
  11520.  
  11521. .NoSpecialTask    move.l    GlobalTagAdr(a4),d0        ; Check for global settings
  11522.         beq.s    .NoTagTsks            ; No settings -> No Patch
  11523.         move.l    d0,a3                ; Do Patch
  11524.         bsr    DoTagPatches
  11525.         tst.b    d0                ; Changes made ?
  11526.         beq.s    .NoTagTsks            ; Nope -> Normal openup
  11527.  
  11528. .DonePatches    move.l    #TAG_DONE,(a2)+
  11529.         clr.l    (a2)
  11530.         lea    -768(a5),a0
  11531.         move.l    a0,28(sp)            ; Store pointer to new TagList
  11532. .NoTagTsks    move.l    a3,d0
  11533.         movem.l    (sp)+,d2-d7/a0-a6
  11534.         move.l    d0,-(sp)
  11535.         move.l    #OldOpenScreenTagList,d0    ; Open Screen
  11536.         bsr    DoRemember
  11537.         move.l    (sp)+,d1
  11538.         unlk    a5
  11539.         movem.l    RegsAll,-(sp)
  11540.         tst.l    d1
  11541.         beq.s    .End
  11542.         move.l    d1,a3
  11543.         tst.l    d0
  11544.         beq.s    .End
  11545.         move.l    ZeroBase(pc),a4
  11546.         tst.b    TagScreens(a4)
  11547.         beq.s    .End
  11548.         movem.l    d0/a3,-(sp)
  11549.         tst.b    tagscr_CenterScr(a3)        ; recenter screen ?
  11550.         beq.s    .NoCenter
  11551.         move.l    d0,a0                ; Go on
  11552.         bsr    GetDispCols
  11553.         move.w    sc_ViewPort+vp_Modes(a0),d1
  11554.         andi.w    #V_HIRES|V_SUPERHIRES,d1
  11555.         bne.s    .SuperHigh
  11556.         lsr.w    #1,d5
  11557.         bra.s    .MoveOK
  11558. .SuperHigh    andi.w    #V_SUPERHIRES,d1
  11559.         beq.s    .MoveOK
  11560.         add.w    d5,d5
  11561. .MoveOK        sub.w    sc_Width(a0),d5
  11562.         bls.s    .NoCenter
  11563.         lsr.w    #1,d5
  11564.         sub.w    sc_LeftEdge(a0),d5
  11565.         beq.s    .NoCenter
  11566.         moveq    #0,d1
  11567.         move.w    d5,d0
  11568.         RELLIB    MoveScreen,_IntuitionBase
  11569. .NoCenter    movem.l    (sp)+,d0/a3
  11570.         tst.b    tagscr_BlackBorder(a3)        ; Add BlackBorder to screen?
  11571.         beq.s    .End
  11572.         bsr    DoBlackBorder            ; Yep
  11573. .End        movem.l    (sp)+,RegsAll
  11574.         rts
  11575. TermName    dc.b    "term Beta Task",0
  11576.         EVEN
  11577.  
  11578.  
  11579. **********************************************************************
  11580. *                       Add a tag to an array                        *
  11581. * D0 = TagItem                                                       *
  11582. * D1 = TagValue                                                      *
  11583. **********************************************************************
  11584. AddTag        bset    #31,d0
  11585.         move.l    d0,ti_Tag(a2)
  11586.         move.l    d1,ti_Data(a2)
  11587.         addq.l    #ti_SIZEOF,a2
  11588.         rts
  11589.  
  11590.  
  11591. **********************************************************************
  11592. *   Some fine routine to find a tag with shorter calling procedure   *
  11593. *                  Same as FindTagItem()/UtilityLib                  *
  11594. **********************************************************************
  11595. FindTag        bset    #31,d0
  11596.         lea    -768(a5),a0
  11597.         RELLIB    FindTagItem,_UtilityBase
  11598.         tst.l    d0
  11599.         rts
  11600.  
  11601.  
  11602.  
  11603. **********************************************************************
  11604. *               Do the patches for a given list-entry                *
  11605. * A2 = Current address within array                                  *
  11606. * A3 = Pointer to entry                                              *
  11607. * A5 = Pointer to buffer for array on stack                          *
  11608. **********************************************************************
  11609. DoTagPatches    tst.b    tagscr_HardPatch(a3)        ; Patch existing Tags/ens_ ???
  11610.         bne.s    .DoPens
  11611.         move.l    32(sp),d0            ; Get pointer to old TagList
  11612.         bne    .HardDone            ; Yep had one, no patch
  11613.         move.l    28(sp),d0            ; Get pointer to screen
  11614.         beq.s    .DoPens                ; No Screen, no nothing -> go on
  11615.         move.l    d0,a0
  11616.         btst    #4,ns_Type(a0)            ; Extended screen ?
  11617.         beq.s    .DoPens                ; Nope -> patch
  11618.         tst.l    ens_Extension(a0)        ; Tags ???
  11619.         bne    .HardDone            ; Yep -> no patch
  11620.         bclr    #4,ns_Type(a0)            ; Clear extended field (using tags now)
  11621.  
  11622. .DoPens        tst.b    tagscr_Pens(a3)            ; Check for pens and patch, if needed
  11623.         beq.s    .HasPens
  11624.         moveq    #SA_Pens-$80000000,d0
  11625.         bsr.s    FindTag
  11626.         bne.s    .HasPens
  11627.         tst.b    tagscr_SystemPens(a3)
  11628.         beq.s    .Use20Pens
  11629.         move.l    $4.w,a0                ; Check for 3.0 and set pens accordingly
  11630.         cmp.w    #39,LIB_VERSION(a0)
  11631.         beq.s    .Get30Pens
  11632. .Use20Pens    lea    PenDatas(pc),a0
  11633.         bra.s    .SetPens
  11634. .Get30Pens    lea    PenDatas30(pc),a0
  11635. .SetPens    move.l    a0,d1
  11636.         moveq    #SA_Pens-$80000000,d0
  11637.         bsr    AddTag
  11638.  
  11639. .HasPens    tst.b    tagscr_AutoScroll(a3)        ; AutoScroll ???
  11640.         beq.s    .NoAutoScroll
  11641.         moveq    #SA_Overscan-$80000000,d0
  11642.         bsr.s    FindTag
  11643.         beq.s    .NoCompAuto
  11644.         move.l    d0,a0                ; Patch Overscan-Tag to match requirements
  11645.         move.l    #OSCAN_STANDARD,ti_Data(a0)
  11646.         bra.s    .CheckAutoScr
  11647. .NoCompAuto    moveq    #SA_Overscan-$80000000,d0
  11648.         move.l    #OSCAN_STANDARD,d1
  11649.         bsr    AddTag
  11650.  
  11651. .CheckAutoScr    moveq    #SA_AutoScroll-$80000000,d0    ; Check for AutoScroll and patch if needed
  11652.         bsr    FindTag
  11653.         beq.s    .AddAutoScr
  11654.         move.l    d0,a0
  11655.         move.l    #-1,ti_Data(a0)
  11656.         bra.s    .NoAutoScroll
  11657. .AddAutoScr    moveq    #SA_AutoScroll-$80000000,d0
  11658.         moveq    #-1,d1
  11659.         bsr    AddTag
  11660.  
  11661. .NoAutoScroll    tst.b    tagscr_Font(a3)            ; NoFont ?
  11662.         beq.s    .NoFont
  11663.         moveq    #SA_Font-$80000000,d0
  11664.         bsr    FindTag
  11665.         bne.s    .GotFontTag
  11666.         moveq    #SA_Font-$80000000,d0
  11667.         lea    Topaz80(pc),a0
  11668.         move.l    a0,d1
  11669.         bsr    AddTag
  11670.         bra.s    .NoFont
  11671. .GotFontTag    move.l    d0,a0
  11672.         lea    Topaz80(pc),a1
  11673.         move.l    a1,ti_Data(a0)
  11674.  
  11675. .NoFont        move.l    $4.w,a0                ; Check for OS3
  11676.         cmp.w    #39,LIB_VERSION(a0)
  11677.         blt.s    .NoLikeWB
  11678.  
  11679.         tst.b    tagscr_Interleave(a3)        ; Interleaved BitMaps ?
  11680.         beq.s    .NoInterleave
  11681.         moveq    #SA_Interleaved-$80000000,d0
  11682.         bsr    FindTag
  11683.         bne.s    .GotInterleave
  11684.         moveq    #SA_Interleaved-$80000000,d0
  11685.         moveq    #-1,d1
  11686.         bsr    AddTag
  11687.         bra.s    .NoInterleave
  11688. .GotInterleave    move.l    d0,a0
  11689.         move.l    #-1,ti_Data(a0)
  11690.  
  11691. .NoInterleave    tst.b    tagscr_LikeWB(a3)        ; Like WB ?
  11692.         beq.s    .NoLikeWB
  11693.         moveq    #SA_LikeWorkbench-$80000000,d0
  11694.         bsr    FindTag
  11695.         bne.s    .GotLikeWB
  11696.         moveq    #SA_LikeWorkbench-$80000000,d0
  11697.         moveq    #-1,d1
  11698.         bsr    AddTag
  11699.         bra    .NoScrWidth
  11700. .GotLikeWB    move.l    d0,a0
  11701.         move.l    #-1,ti_Data(a0)
  11702.         bra    .NoScrWidth
  11703.  
  11704. .NoLikeWB    tst.b    tagscr_Monitor(a3)        ; Set DisplayID ?
  11705.         beq    .NoScrWidth
  11706.         link    a5,#-dis_SIZEOF
  11707.         sub.l    a0,a0
  11708.         lea    -dis_SIZEOF(a5),a1
  11709.         move.l    #dis_SIZEOF,d0
  11710.         move.l    #DTAG_DISP,d1
  11711.         move.l    tagscr_DisplayID(a3),d2
  11712.         RELLIB    GetDisplayInfoData,_GfxBase
  11713.         tst.l    d0
  11714.         bne.s    .CheckInfo
  11715.         unlk    a5
  11716.         bra.s    .NoScrWidth
  11717. .CheckInfo    lea    -dis_SIZEOF(a5),a0
  11718.         tst.w    dis_NotAvailable(a0)
  11719.         beq.s    .DoIt
  11720.         unlk    a5
  11721.         bra.s    .NoScrWidth
  11722. .DoIt        unlk    a5
  11723.         moveq    #SA_DisplayID-$80000000,d0
  11724.         bsr    FindTag
  11725.         beq.s    .NoIDFound
  11726.         move.l    d0,a0
  11727.         move.l    tagscr_DisplayID(a3),d0
  11728.         move.l    d0,ti_Data(a0)
  11729.         bra.s    .NoDisplayID
  11730. .NoIDFound    moveq    #SA_DisplayID-$80000000,d0
  11731.         move.l    tagscr_DisplayID(a3),d1
  11732.         bsr    AddTag
  11733.  
  11734. .NoDisplayID    move.l    tagscr_Height(a3),d7        ; Height specified ???
  11735.         beq.s    .NoScrHeight
  11736.         moveq    #SA_Height-$80000000,d0
  11737.         bsr    FindTag
  11738.         bne.s    .GotScrHeight
  11739.         moveq    #SA_Height-$80000000,d0
  11740.         move.l    d7,d1
  11741.         bsr    AddTag
  11742.         bra.s    .NoScrHeight
  11743. .GotScrHeight    move.l    d0,a0
  11744.         move.l    d7,ti_Data(a0)
  11745.  
  11746. .NoScrHeight    move.l    tagscr_Width(a3),d7        ; Width specified ???
  11747.         beq.s    .NoScrWidth
  11748.         moveq    #SA_Width-$80000000,d0
  11749.         bsr    FindTag
  11750.         bne.s    .GotScrWidth
  11751.         moveq    #SA_Width-$80000000,d0
  11752.         move.l    d7,d1
  11753.         bsr    AddTag
  11754.         bra.s    .NoScrWidth
  11755. .GotScrWidth    move.l    d0,a0
  11756.         move.l    d7,ti_Data(a0)
  11757.  
  11758. .NoScrWidth    moveq    #1,d0
  11759.         rts
  11760. .HardDone    moveq    #0,d0
  11761.         rts
  11762. PenDatas    dc.w    3,1,1,2,1,3,1,0,2,-1
  11763. PenDatas30    dc.w    3,1,1,2,1,3,1,0,2,1,2,1,-1
  11764. Topaz80        dc.l    TopazName
  11765.         dc.w    8
  11766.         dc.b    FS_NORMAL,FPF_ROMFONT
  11767. TopazName    dc.b    "topaz.font",0
  11768.         even
  11769.  
  11770.  
  11771.  
  11772. **********************************************************************
  11773. *                     Install/Remove BlackBorder                     *
  11774. **********************************************************************
  11775. DoBlackBorder    tst.b    BlackBorderOk(a4)
  11776.         beq.s    NoBlackOK
  11777.         tst.l    d0
  11778.         beq.s    NoBlackOK
  11779. DoBlackBorderOk    movem.l    d0-d1/a0-a3,-(sp)        ; Add BlackBorder tag to ViewPort
  11780.         move.l    d0,a2
  11781.         move.l    sc_ViewPort+vp_ColorMap(a2),a0
  11782.         lea    BlackTags(pc),a1
  11783.         RELLIB    VideoControl,_GfxBase
  11784.         move.l    a2,a0
  11785.         RELLIB    MakeScreen,_IntuitionBase
  11786.         DOLIB    ViewAddress            ; I don`t use RethinDisplay() `cause
  11787.         lea    sc_ViewPort(a2),a1        ; it makeweird thinks on a OpenWorkBench() call
  11788.         move.l    d0,a2                ; just calc new copper-lists for ColorMap
  11789.         move.l    d0,a0
  11790.         RELLIB    MakeVPort,_GfxBase
  11791.         move.l    a2,a1
  11792.         DOLIB    MrgCop
  11793.         move.l    a2,a1
  11794.         DOLIB    LoadView
  11795.         movem.l    (sp)+,d0-d1/a0-a3
  11796. NoBlackOK    rts
  11797. BlackTags    dc.l    VTAG_BORDERBLANK_SET,-1,TAG_DONE,0
  11798.  
  11799.  
  11800.  
  11801. **********************************************************************
  11802. *                  Redo all screens for BlackBorder                  *
  11803. **********************************************************************
  11804. ReBlackBorder    move.l    GlobalTagAdr(a4),d0
  11805.         beq.s    NoReBlack
  11806.         move.l    d0,a0
  11807.         tst.b    tagscr_BlackBorder(a0)
  11808.         beq.s    NoReBlack
  11809.         move.l    #VTAG_BORDERBLANK_SET,BlackTags
  11810. ReBlackBorder2    tst.b    BlackBorderOk(a4)
  11811.         beq.s    NoReBlack
  11812.         moveq    #0,d0
  11813.         RELLIB    LockIBase,_IntuitionBase
  11814.         move.l    ib_FirstScreen(a6),a2
  11815.         move.l    d0,a0
  11816.         DOLIB    UnlockIBase
  11817.         lea    WBScrName(pc),a0
  11818.         RELLIB    LockPubScreen,_IntuitionBase
  11819.         move.l    d0,a3
  11820.         CALLSYS    Forbid
  11821. .LoopScreens    move.l    a2,d0
  11822.         beq.s    .NoScrs
  11823.         movem.l    a2/a3,-(sp)
  11824.         bsr    DoBlackBorderOk
  11825.         movem.l    (sp)+,a2/a3
  11826.         move.l    sc_NextScreen(a2),a2
  11827.         bra.s    .LoopScreens
  11828. .NoScrs        CALLSYS    Permit
  11829.         move.l    a3,d0
  11830.         beq.s    NoReBlack
  11831.         move.l    d0,a1
  11832.         lea    WBScrName(pc),a0
  11833.         RELLIB    UnlockPubScreen,_IntuitionBase
  11834. NoReBlack    rts
  11835.  
  11836.  
  11837.  
  11838. **********************************************************************
  11839. *               Get currently available DisplayColumns               *
  11840. **********************************************************************
  11841. GetDispCols    move.l    _GfxBase(a4),a3
  11842.         move.w    gb_NormalDisplayColumns(a3),d5
  11843.         rts
  11844.  
  11845.  
  11846.  
  11847. **********************************************************************
  11848. *                      Screen to front routine                       *
  11849. **********************************************************************
  11850. NewScreenToFront
  11851.         move.l    #OldScreenToFront,d0
  11852.         bsr.s    DoRemember
  11853.         bra    RestoreWindow
  11854.  
  11855.  
  11856. **********************************************************************
  11857. *                           Screen to back                           *
  11858. **********************************************************************
  11859. NewScreenToBack    move.l    #OldScreenToBack,d0
  11860.         bsr.s    DoRemember
  11861.         bra    RestoreWindow
  11862.  
  11863.  
  11864. **********************************************************************
  11865. *                         Workbench to front                         *
  11866. **********************************************************************
  11867. NewWBenchToFront
  11868.         move.l    #OldWBenchToFront,d0
  11869.         bsr.s    DoRemember
  11870.         bra    RestoreWindow
  11871.  
  11872.  
  11873. **********************************************************************
  11874. *                         Workbench to back                          *
  11875. **********************************************************************
  11876. NewWBenchToBack    move.l    #OldWBenchToBack,d0
  11877.         bsr.s    DoRemember
  11878.         bra    RestoreWindow
  11879.  
  11880.  
  11881. **********************************************************************
  11882. *                            Close screen                            *
  11883. **********************************************************************
  11884. NewCloseScreen    bsr    GetSemaphore
  11885.         move.l    ZeroBase(pc),a1
  11886.         lea    ScreenList(a1),a1
  11887.         moveq    #MAXSCREENS-1,d0
  11888. .Loop        cmp.l    (a1),a0
  11889.         beq.s    .GotIt
  11890.         addq.l    #8,a1
  11891.         dbf    d0,.Loop
  11892. .End        move.l    ZeroBase(pc),a1
  11893.         pea    RestoreWindow(pc)
  11894.         move.l    OldCloseScreen(a1),-(sp)
  11895.         bsr    FreeSemaphore
  11896.         rts
  11897. .GotIt        clr.l    (a1)
  11898.         bra.s    .End
  11899.  
  11900.  
  11901.  
  11902.  
  11903. **********************************************************************
  11904. *                  Stub for calling system routines                  *
  11905. **********************************************************************
  11906. DoRemember    bsr    GetSemaphore
  11907.         bsr.s    RememberWindow            ; Remember the active window
  11908.         move.l    a0,-(sp)
  11909.         move.l    ZeroBase(pc),a0
  11910.         move.l    0(a0,d0.w),d0
  11911.         move.l    (sp)+,a0
  11912.         move.l    d0,-(sp)
  11913.         bsr    FreeSemaphore
  11914.         rts
  11915.  
  11916.  
  11917.  
  11918. **********************************************************************
  11919. *                   Store screen/window addresses                    *
  11920. **********************************************************************
  11921. RememberWindow    movem.l    RegsAll,-(sp)
  11922.         move.l    ZeroBase(pc),a4
  11923.         CALLSYS    Forbid
  11924.         move.l    _IntuitionBase(a4),a0
  11925.         move.l    ib_ActiveWindow(a0),a1
  11926.         move.l    ib_ActiveScreen(a0),a0
  11927.         CALLSYS    Permit
  11928.         move.l    a0,d0
  11929.         beq.s    .End
  11930.         move.l    a1,d0
  11931.         beq.s    .End
  11932.         lea    ScreenList(a4),a2        ; Check if screen`s already in list
  11933.         moveq    #MAXSCREENS-1,d0
  11934. .Find        cmp.l    (a2),a0
  11935.         beq.s    .GotIt
  11936.         addq.l    #8,a2
  11937.         dbf    d0,.Find
  11938.         lea    ScreenList(a4),a2        ; Store screen
  11939.         moveq    #MAXSCREENS-1,d0
  11940. .Stick        tst.l    (a2)
  11941.         beq.s    .Save
  11942.         addq.l    #8,a2
  11943.         dbf    d0,.Stick
  11944.         bra.s    .End
  11945. .Save        move.l    a0,(a2)+
  11946.         move.l    a1,(a2)
  11947.         bra.s    .End
  11948. .GotIt        move.l    a1,4(a2)
  11949. .End        movem.l    (sp)+,RegsAll
  11950.         rts
  11951.  
  11952.  
  11953.  
  11954.  
  11955. **********************************************************************
  11956. *       This routine reactivates the previously active window        *
  11957. **********************************************************************
  11958. RestoreWindow    bsr    GetSemaphore
  11959.         movem.l    RegsAll,-(sp)            ; Search for active screen in list
  11960.         move.l    ZeroBase(pc),a4
  11961.         lea    ScreenList(a4),a1        ; Get ScreenList
  11962.         move.l    _IntuitionBase(a4),a6
  11963.         move.l    ib_FirstScreen(a6),a0        ; Get first screen
  11964.         move.l    a0,d0
  11965.         beq.s    .End
  11966.         moveq    #MAXSCREENS-1,d0
  11967. .Loop        cmp.l    (a1),a0                ; Hunt for screen in list
  11968.         beq.s    .GotIt
  11969.         addq.l    #8,a1
  11970.         dbf    d0,.Loop
  11971.         move.l    a0,a2                ; Copy pointer to screen
  11972.         bra.s    .FindWin            ; This screen isn`t within the lis
  11973.                             ; So activate the window underneith the mouse
  11974. .GotIt        move.l    4(a1),a0            ; ReActivate it`s window
  11975.         move.l    (a1),a1                ; Get pointer to screen
  11976.         move.l    a1,a2                ; Copy pointer to screen
  11977.         move.l    sc_FirstWindow(a1),a1        ; Window still living ???
  11978. .CheckWinEx    move.l    a1,d0
  11979.         beq.s    .FindWin
  11980.         cmp.l    a1,a0                ; Yep -> activate it
  11981.         beq.s    .Skip
  11982.         move.l    wd_NextWindow(a1),a1
  11983.         bra.s    .CheckWinEx
  11984. .FindWin    RELLIB    FindWindow,_KCXBase        ; Otherwise activate window underneith the mouse
  11985.         tst.l    d0                ; Got a window ?
  11986.         beq.s    .TakeFirst            ; Nope -> Take first available
  11987.         move.l    d0,a0
  11988.         move.l    lr_Window(a0),d0        ; Window for layer ???
  11989.         beq.s    .TakeFirst            ; Nope -> Take first window
  11990.         move.l    d0,a0
  11991.         bra.s    .Skip
  11992. .TakeFirst    move.l    sc_FirstWindow(a2),d0        ; Get first window
  11993.         beq.s    .End                ; None there -> Quit
  11994.         move.l    d0,a0                ; Activate window
  11995. .Skip        tst.b    WindowReAct(a4)
  11996.         beq.s    .End
  11997.         RELLIB    ActivateWindow,_IntuitionBase
  11998. .End        movem.l    (sp)+,RegsAll
  11999.         bsr    FreeSemaphore
  12000.         rts
  12001.  
  12002.  
  12003.  
  12004.  
  12005. **********************************************************************
  12006. *                       New CreateUpfrontLayer                       *
  12007. **********************************************************************
  12008. NewCreateUpfrontLayer
  12009.         movem.l    d0-d7/a0-a6,-(sp)
  12010.         move.l    ZeroBase(pc),a4
  12011.         tst.b    Disabled(a4)
  12012.         bne    .NoExplode
  12013.         tst.b    ExpWindows(a4)
  12014.         beq    .NoExplode
  12015.         tst.l    ExpFrames(a4)
  12016.         beq    .NoExplode
  12017.         and.l    #LAYERBACKDROP,d4        ; Backdrop-Layer ?
  12018.         bne    .NoExplode            ; No explode
  12019.         move.l    a0,a3
  12020.         bsr    GetScreen
  12021.         move.l    a3,d7
  12022.         beq    .NoExplode
  12023.         move.l    ExpFrames(a4),-(sp)
  12024.         sub.l    d0,d2                ; Get dims
  12025.         sub.l    d1,d3
  12026.         tst.b    MouseCenter(a4)
  12027.         bne.s    .GetMousePos
  12028.         movem.l    d0-d3/d6-d7/a0-a6,-(sp)
  12029.         link    a5,#-dim_SIZEOF
  12030.         lea    sc_ViewPort(a3),a0
  12031.         RELLIB    GetVPModeID,_GfxBase
  12032.         sub.l    a0,a0
  12033.         lea    -dim_SIZEOF(a5),a1
  12034.         move.l    d0,d2
  12035.         move.l    #dim_SIZEOF,d0
  12036.         move.l    #DTAG_DIMS,d1
  12037.         DOLIB    GetDisplayInfoData
  12038.         lea    -dim_SIZEOF+dim_TxtOScan(a5),a0
  12039.         move.w    ra_MaxX(a0),d4
  12040.         lsr.w    #1,d4
  12041.         move.w    ra_MaxY(a0),d5
  12042.         lsr.w    #1,d5
  12043.         move.w    sc_LeftEdge(a3),d0
  12044.         neg.w    d0
  12045.         add.w    d0,d4
  12046.         move.w    sc_TopEdge(a3),d0
  12047.         neg.w    d0
  12048.         add.w    d0,d5
  12049.         ext.l    d4
  12050.         ext.l    d5
  12051.         unlk    a5
  12052.         movem.l    (sp)+,d0-d3/d6-d7/a0-a6
  12053.         bra.s    .GotPos
  12054. .GetMousePos    move.w    sc_MouseX(a3),d4
  12055.         bge.s    .MouseX
  12056.         moveq    #0,d4
  12057. .MouseX        cmp.w    sc_Width(a3),d4
  12058.         blt.s    .MouseXa
  12059.         move.w    sc_Width(a3),d4
  12060.         subq.w    #1,d4
  12061. .MouseXa    move.w    sc_MouseY(a3),d5
  12062.         bge.s    .MouseY
  12063.         moveq    #0,d5
  12064. .MouseY        cmp.w    sc_Height(a3),d5
  12065.         blt.s    .MouseYa
  12066.         move.w    sc_Height(a3),d5
  12067.         subq.w    #1,d5
  12068. .MouseYa    ext.l    d4
  12069.         ext.l    d5
  12070. .GotPos        movem.l    d2-d3,-(sp)
  12071.         sub.l    d5,d1
  12072.         move.l    d1,-(sp)
  12073.         sub.l    d4,d0
  12074.         move.l    d0,-(sp)
  12075.         pea    1.W
  12076.         pea    1.W
  12077.         movem.l    d4-d5,-(sp)
  12078.         move.l    a3,-(sp)
  12079.         jsr    LayerFade
  12080.         lea    40(sp),sp
  12081. .NoExplode    movem.l    (sp)+,d0-d7/a0-a6
  12082.         move.l    a5,-(sp)
  12083.         move.l    ZeroBase(pc),a5
  12084.         move.l    OldCreateUpfrontLayer(a5),a5
  12085.         jsr    (a5)
  12086.         move.l    (sp)+,a5
  12087.         rts
  12088.  
  12089.  
  12090. **********************************************************************
  12091. *                     New CreateUpfrontHookLayer                     *
  12092. **********************************************************************
  12093. NewCreateUpfrontHookLayer
  12094.         movem.l    d0-d7/a0-a6,-(sp)
  12095.         move.l    ZeroBase(pc),a4
  12096.         tst.b    Disabled(a4)
  12097.         bne    .NoExplode
  12098.         tst.b    ExpWindows(a4)
  12099.         beq    .NoExplode
  12100.         tst.l    ExpFrames(a4)
  12101.         beq    .NoExplode
  12102.         and.l    #LAYERBACKDROP,d4        ; BackDrop-Layer ?
  12103.         bne    .NoExplode            ; No explode
  12104.         move.l    a0,a3
  12105.         bsr    GetScreen
  12106.         move.l    a3,d7
  12107.         beq    .NoExplode
  12108.         move.l    ExpFrames(a4),-(sp)
  12109.         sub.l    d0,d2                ; Get dims
  12110.         sub.l    d1,d3
  12111.         tst.b    MouseCenter(a4)
  12112.         bne.s    .GetMouse
  12113.         movem.l    d0-d3/d6-d7/a0-a6,-(sp)
  12114.         link    a5,#-dim_SIZEOF
  12115.         lea    sc_ViewPort(a3),a0
  12116.         RELLIB    GetVPModeID,_GfxBase
  12117.         sub.l    a0,a0
  12118.         lea    -dim_SIZEOF(a5),a1
  12119.         move.l    d0,d2
  12120.         move.l    #dim_SIZEOF,d0
  12121.         move.l    #DTAG_DIMS,d1
  12122.         DOLIB    GetDisplayInfoData
  12123.         lea    -dim_SIZEOF+dim_TxtOScan(a5),a0
  12124.         move.w    ra_MaxX(a0),d4
  12125.         lsr.w    #1,d4
  12126.         move.w    ra_MaxY(a0),d5
  12127.         lsr.w    #1,d5
  12128.         move.w    sc_LeftEdge(a3),d0
  12129.         neg.w    d0
  12130.         add.w    d0,d4
  12131.         move.w    sc_TopEdge(a3),d0
  12132.         neg.w    d0
  12133.         add.w    d0,d5
  12134.         ext.l    d4
  12135.         ext.l    d5
  12136.         unlk    a5
  12137.         movem.l    (sp)+,d0-d3/d6-d7/a0-a6
  12138.         bra.s    .GotPos
  12139. .GetMouse    move.w    sc_MouseX(a3),d4
  12140.         bge.s    .MouseX
  12141.         moveq    #0,d4
  12142. .MouseX        cmp.w    sc_Width(a3),d4
  12143.         blt.s    .MouseXa
  12144.         move.w    sc_Width(a3),d4
  12145.         subq.w    #1,d4
  12146. .MouseXa    move.w    sc_MouseY(a3),d5
  12147.         bge.s    .MouseY
  12148.         moveq    #0,d5
  12149. .MouseY        cmp.w    sc_Height(a3),d5
  12150.         blt.s    .MouseYa
  12151.         move.w    sc_Height(a3),d5
  12152.         subq.w    #1,d5
  12153. .MouseYa    ext.l    d4
  12154.         ext.l    d5
  12155. .GotPos        move.l    d3,-(sp)
  12156.         move.l    d2,-(sp)
  12157.         sub.l    d5,d1
  12158.         move.l    d1,-(sp)
  12159.         sub.l    d4,d0
  12160.         move.l    d0,-(sp)
  12161.         pea    1.W
  12162.         pea    1.W
  12163.         move.l    d5,-(sp)
  12164.         move.l    d4,-(sp)
  12165.         move.l    a3,-(sp)
  12166.         jsr    LayerFade
  12167.         lea    40(sp),sp
  12168. .NoExplode    movem.l    (sp)+,d0-d7/a0-a6
  12169.         move.l    a5,-(sp)
  12170.         move.l    ZeroBase(pc),a5
  12171.         move.l    OldCreateUpfrontHookLayer(a5),a5
  12172.         jsr    (a5)
  12173.         move.l    (sp)+,a5
  12174.         rts
  12175.  
  12176.  
  12177.  
  12178.  
  12179.  
  12180. **********************************************************************
  12181. *                      This is our DeleteLayer                       *
  12182. **********************************************************************
  12183. NewDeleteLayer    movem.l    d2-d7/a2-a6,-(sp)
  12184.         move.l    ZeroBase(pc),a4
  12185.         moveq    #0,d4                ; Clear screen pointer
  12186.         move.w    lr_Flags(a1),d0            ; BACKDROP layer ?
  12187.         and.w    #LAYERBACKDROP,d0
  12188.         bne.s    .BackLayer            ; Yep -> no frames
  12189.         move.l    a1,a3
  12190.         move.l    lr_LayerInfo(a3),a3
  12191.         bsr    GetScreen            ; Get layer`s screen
  12192.         move.l    a3,d4
  12193.         move.w    lr_MinX(a1),d7            ; Get layers dims
  12194.         move.w    lr_MinY(a1),d1
  12195.         move.w    lr_MaxX(a1),d2
  12196.         move.w    lr_MaxY(a1),d3
  12197.         ext.l    d7
  12198.         ext.l    d1
  12199.         ext.l    d2
  12200.         ext.l    d3
  12201.         sub.l    d7,d2
  12202.         sub.l    d1,d3
  12203. .BackLayer    movem.l    d1-d7,-(sp)
  12204.         move.l    OldDeleteLayer(a4),a3        ; Delete layer
  12205.         jsr    (a3)
  12206.         movem.l    (sp)+,d1-d7
  12207.         move.l    d0,a3
  12208.         beq    .NoImplode
  12209.         tst.b    Disabled(a4)
  12210.         bne    .NoImplode
  12211.         tst.b    ExpWindows(a4)
  12212.         beq    .NoImplode
  12213.         tst.l    ImpFrames(a4)
  12214.         beq    .NoImplode
  12215.         move.l    d7,d0
  12216.  
  12217.         tst.l    d4                ; Do we have a screen ?
  12218.         beq    .NoImplode
  12219.         move.l    a3,-(sp)
  12220.         move.l    ImpFrames(a4),-(sp)
  12221.         move.l    d4,a3
  12222.         move.l    d2,d5
  12223.         move.l    d3,d6
  12224.         neg.l    d5
  12225.         neg.l    d6
  12226.         move.l    d6,-(sp)
  12227.         move.l    d5,-(sp)
  12228.         tst.b    MouseCenter(a4)
  12229.         bne.s    .GetMouse
  12230.         movem.l    d0-d4/d7/a0-a6,-(sp)
  12231.         link    a5,#-dim_SIZEOF
  12232.         lea    sc_ViewPort(a3),a0
  12233.         RELLIB    GetVPModeID,_GfxBase
  12234.         sub.l    a0,a0
  12235.         lea    -dim_SIZEOF(a5),a1
  12236.         move.l    d0,d2
  12237.         move.l    #dim_SIZEOF,d0
  12238.         move.l    #DTAG_DIMS,d1
  12239.         DOLIB    GetDisplayInfoData
  12240.         lea    -dim_SIZEOF+dim_TxtOScan(a5),a0
  12241.         move.w    ra_MaxX(a0),d5
  12242.         lsr.w    #1,d5
  12243.         move.w    ra_MaxY(a0),d6
  12244.         lsr.w    #1,d6
  12245.         move.w    sc_LeftEdge(a3),d0
  12246.         neg.w    d0
  12247.         add.w    d0,d5
  12248.         move.w    sc_TopEdge(a3),d0
  12249.         neg.w    d0
  12250.         add.w    d0,d6
  12251.         ext.l    d5
  12252.         ext.l    d6
  12253.         unlk    a5
  12254.         movem.l    (sp)+,d0-d4/d7/a0-a6
  12255.         sub.l    d1,d6
  12256.         move.l    d6,-(sp)
  12257.         sub.l    d7,d5
  12258.         move.l    d5,-(sp)
  12259.         bra.s    .GotPos
  12260. .GetMouse    move.w    sc_MouseY(a3),d5
  12261.         bge.s    .MouseY
  12262.         moveq    #0,d5
  12263. .MouseY        cmp.w    sc_Height(a3),d5
  12264.         blt.s    .MouseYa
  12265.         move.w    sc_Height(a3),d5
  12266.         subq.w    #1,d5
  12267. .MouseYa    ext.l    d5
  12268.         sub.l    d1,d5
  12269.         move.l    d5,-(sp)
  12270.         move.w    sc_MouseX(a3),d5
  12271.         bge.s    .MouseX
  12272.         moveq    #0,d5
  12273. .MouseX        cmp.w    sc_Width(a3),d5
  12274.         blt.s    .MouseXa
  12275.         move.w    sc_Width(a3),d5
  12276.         subq.w    #1,d5
  12277. .MouseXa    ext.l    d5
  12278.         sub.l    d7,d5
  12279.         move.l    d5,-(sp)
  12280. .GotPos        move.l    d3,-(sp)
  12281.         move.l    d2,-(sp)
  12282.         move.l    d1,-(sp)
  12283.         move.l    d7,-(sp)
  12284.         move.l    d4,-(sp)
  12285.         jsr    LayerFade            ; Implode
  12286.         lea    40(sp),sp
  12287.         move.l    (sp)+,a3
  12288. .NoImplode    move.l    a3,d0                ; Restore returnvalue
  12289.         movem.l    (sp)+,d2-d7/a2-a6
  12290.         rts
  12291.  
  12292.  
  12293.  
  12294. **********************************************************************
  12295. *                    New Move/Size Layer function                    *
  12296. **********************************************************************
  12297. NewMoveSizeLayer
  12298.         movem.l    d1-d7/a0-a6,-(sp)
  12299.         move.l    ZeroBase(pc),a4
  12300.         movem.l    RegsAll,-(sp)
  12301.         tst.b    Disabled(a4)
  12302.         bne.s    .NoMove
  12303.         tst.b    ExpWindows(a4)
  12304.         beq.s    .NoMove
  12305.         move.l    a0,a3
  12306.         move.l    lr_LayerInfo(a3),a3
  12307.         bsr.s    GetScreen
  12308.         move.l    a3,d4                ; Get Screen pointer
  12309.         beq.s    .NoMove
  12310.         tst.w    d2
  12311.         bne.s    .NoMoveFrames
  12312.         tst.w    d3
  12313.         bne.s    .NoMoveFrames
  12314.         move.l    MoveFrames(a4),d7
  12315.         beq.s    .NoMove
  12316.         bra.s    .DoSize
  12317. .NoMoveFrames    move.l    SizeFrames(a4),d7
  12318.         beq.s    .NoMove
  12319. .DoSize        move.l    d7,-(sp)
  12320.         move.l    d3,-(sp)
  12321.         move.l    d2,-(sp)
  12322.         move.l    d1,-(sp)
  12323.         move.l    d0,-(sp)
  12324.         movem.w    lr_MinX(a0),d0-d3
  12325.         ext.l    d0
  12326.         ext.l    d1
  12327.         ext.l    d2
  12328.         ext.l    d3
  12329.         sub.l    d0,d2
  12330.         sub.l    d1,d3
  12331.         move.l    d3,-(sp)
  12332.         move.l    d2,-(sp)
  12333.         move.l    d1,-(sp)
  12334.         move.l    d0,-(sp)
  12335.         move.l    d4,-(sp)
  12336.         jsr    LayerFade
  12337.         lea    40(sp),sp
  12338. .NoMove        movem.l    (sp)+,RegsAll
  12339.         move.l    ZeroBase(pc),a3
  12340.         move.l    OldMoveSizeLayer(a3),a3        ; Move layer
  12341.         jsr    (a3)
  12342.         movem.l    (sp)+,d1-d7/a0-a6
  12343.         rts
  12344.  
  12345.  
  12346. **********************************************************************
  12347. *             Get address of corresponding to Layer_Info             *
  12348. * A3 = Address of Layer_Info                                         *
  12349. **********************************************************************
  12350. GetScreen    movem.l    d0-d7/a0-a1,-(sp)
  12351.         move.l    _IntuitionBase(a4),a0
  12352.         move.l    ib_FirstScreen(a0),a0
  12353. .FindScreen    move.l    a0,d0
  12354.         beq.s    .GotScreen
  12355.         move.l    a0,a1
  12356.         lea    sc_LayerInfo(a1),a1
  12357.         cmp.l    a1,a3
  12358.         beq.s    .GotScreen
  12359.         move.l    sc_NextScreen(a0),a0
  12360.         bra.s    .FindScreen
  12361. .GotScreen    move.l    a0,a3
  12362.         movem.l    (sp)+,d0-d7/a0-a1
  12363.         rts
  12364.  
  12365.  
  12366.  
  12367. **********************************************************************
  12368. *                      New autorequest routine                       *
  12369. **********************************************************************
  12370. NewAutoRequest    pea    OldAutoRequest
  12371.         bra.s    DoRequest
  12372.  
  12373.  
  12374. **********************************************************************
  12375. *                      New Easyrequest routine                       *
  12376. **********************************************************************
  12377. NewEasyRequestArgs
  12378.         pea    OldEasyRequestArgs
  12379.         bra.s    DoRequest
  12380.  
  12381.  
  12382.  
  12383.  
  12384. **********************************************************************
  12385. *                  Do stuff for calling a requester                  *
  12386. **********************************************************************
  12387. DoRequest    movem.l    d1-d7/a0-a6,-(sp)
  12388.         move.l    ZeroBase(pc),a4
  12389.         move.l    d0,-(sp)
  12390.         bsr    OnScreen
  12391.         bsr    GetSemaphore
  12392.         move.l    60(sp),d0
  12393.         addq.w    #1,RequestsOpen(a4)
  12394.         move.b    #1,TimeReset(a4)
  12395.         clr.b    ScrTimeOut(a4)
  12396.         move.l    0(a4,d0.w),d7
  12397.         bsr    FreeSemaphore
  12398.         move.l    (sp)+,d0
  12399.         pea    .End
  12400.         move.l    d7,-(sp)
  12401.         movem.l    8(sp),d1-d7/a0-a6
  12402.         rts
  12403. .End        bsr    GetSemaphore
  12404.         move.l    ZeroBase(pc),a4
  12405.         subq.w    #1,RequestsOpen(a4)
  12406.         movem.l    (sp)+,d1-d7/a0-a6
  12407.         addq.l    #4,sp
  12408.         bra    FreeSemaphore
  12409.  
  12410.  
  12411. **********************************************************************
  12412. *                          New DisplayBeep                           *
  12413. **********************************************************************
  12414. NewDisplayBeep    bsr    GetSemaphore
  12415.         move.l    a4,-(sp)
  12416.         move.l    ZeroBase(pc),a4
  12417.         move.l    OldDisplayBeep(a4),d0
  12418.         move.b    NoDisplayBeep(a4),d1
  12419.         move.l    (sp)+,a4
  12420.         tst.b    d1
  12421.         bne.s    .End
  12422.         pea    .End(pc)
  12423.         move.l    d0,-(sp)
  12424.         rts
  12425. .End        bra    FreeSemaphore
  12426.  
  12427.  
  12428.  
  12429.  
  12430. **********************************************************************
  12431. *       New MatchFirst routine, for creating a "real" *-Joker        *
  12432. **********************************************************************
  12433. NewMatchFirst    movem.l    a4/a5,-(sp)
  12434.         link    a5,#-$102
  12435.         move.l    d1,a0
  12436.         lea    -$100(a5),a1
  12437.         move.l    a1,d1
  12438. .CopyName    move.b    (a0)+,d0
  12439.         cmp.b    #'*',d0
  12440.         bne.s    .GoOn
  12441.         move.b    #'#',(a1)+
  12442.         move.b    #'?',d0
  12443. .GoOn        move.b    d0,(a1)+
  12444.         tst.b    d0
  12445.         bne.s    .CopyName
  12446.         move.l    ZeroBase(pc),a4
  12447.         move.l    OldMatchFirst(a4),a4
  12448.         jsr    (a4)
  12449.         unlk    a5
  12450.         movem.l    (sp)+,a4/a5
  12451.         rts
  12452.  
  12453.  
  12454.  
  12455. **********************************************************************
  12456. *                 New Open WorkBench for BlackBorder                 *
  12457. **********************************************************************
  12458. GD_Display                             EQU    0
  12459. NewOpenWorkBench
  12460.         move.l    #OldOpenWorkBench,d0
  12461.         bsr    DoRemember
  12462.         movem.l    RegsAll,-(sp)
  12463.         CALLSYS    Forbid
  12464.         move.l    ZeroBase(pc),a4
  12465.         move.b    OldClockState(a4),d0
  12466.         move.b    d0,ShowClock(a4)
  12467.         move.l    #GD_Display,d1
  12468.         lea    ClockDefGads(a4),a0
  12469.         move.l    ClockDefHandle(a4),a1
  12470.         RELLIB    SetCheckBox,_KCXBase
  12471.         CALLSYS    Permit
  12472.         movem.l    (sp)+,RegsAll
  12473.         rts
  12474.  
  12475.  
  12476.  
  12477. **********************************************************************
  12478. *                  Patched close workbench routine                   *
  12479. **********************************************************************
  12480. NewCloseWorkBench
  12481.         movem.l    d1-d7/a0-a6,-(sp)
  12482.         CALLSYS    Forbid
  12483.         move.l    ZeroBase(pc),a4
  12484.         move.b    ShowClock(a4),d0
  12485.         move.b    d0,OldClockState(a4)
  12486.         clr.b    ShowClock(a4)
  12487.         moveq    #0,d0
  12488.         move.l    #GD_Display,d1
  12489.         lea    ClockDefGads(a4),a0
  12490.         move.l    ClockDefHandle(a4),a1
  12491.         RELLIB    SetCheckBox,_KCXBase
  12492.         CALLSYS    Permit
  12493.         move.l    (13*4)(sp),a6
  12494.         move.l    OldCloseWorkBench(a4),a0
  12495.         jsr    (a0)
  12496.         tst.l    d0
  12497.         bne.s    .NoReAct
  12498.         move.l    d0,-(sp)
  12499.         CALLSYS    Forbid
  12500.         move.b    OldClockState(a4),d0
  12501.         move.b    d0,ShowClock(a4)
  12502.         move.l    #GD_Display,d1
  12503.         lea    ClockDefGads(a4),a0
  12504.         move.l    ClockDefHandle(a4),a1
  12505.         RELLIB    SetCheckBox,_KCXBase
  12506.         CALLSYS    Permit
  12507.         move.l    (sp)+,d0
  12508. .NoReAct    movem.l    (sp)+,d1-d7/a0-a6
  12509.         rts
  12510.  
  12511.  
  12512.  
  12513.  
  12514.  
  12515. ZeroBase    dc.l    0
  12516.  
  12517.  
  12518.  
  12519.  
  12520. **********************************************************************
  12521. *              Stub for calling the library`s EditHook               *
  12522. **********************************************************************
  12523. MyStrEditFunc    movem.l    RegsAll,-(sp)
  12524.         move.l    h_Data(a0),a4
  12525.         RELLIB    StrEditFunc,_KCXBase
  12526.         movem.l    (sp)+,RegsAll
  12527.         rts
  12528.  
  12529.  
  12530.  
  12531.  
  12532. **********************************************************************
  12533. *              FKey-Command : Minimize a window`s size               *
  12534. **********************************************************************
  12535. MinimizeWin    movem.l    RegsAll,-(sp)
  12536.         move.l    _IntuitionBase(a4),a6
  12537.         move.l    ib_ActiveWindow(a6),d0
  12538.         beq.s    .End
  12539.         move.l    d0,a0                ; Get window
  12540.         move.l    wd_Flags(a0),d0
  12541.         and.l    #WFLG_SIZEGADGET,d0
  12542.         beq.s    .End
  12543.         move.w    wd_LeftEdge(a0),d0
  12544.         move.w    wd_TopEdge(a0),d1
  12545.         neg.w    d0
  12546.         neg.w    d1
  12547.         move.w    wd_Width(a0),d2
  12548.         move.w    wd_Height(a0),d3
  12549.         sub.w    wd_MinWidth(a0),d2
  12550.         sub.w    wd_MinHeight(a0),d3
  12551.         neg.w    d2
  12552.         neg.w    d3
  12553.         DOLIB    ChangeWindowBox
  12554. .End        movem.l    (sp)+,RegsAll
  12555.         rts
  12556.  
  12557.  
  12558.  
  12559. **********************************************************************
  12560. *              FKey-Command : Maximize a window`s size               *
  12561. **********************************************************************
  12562. MaximizeWin    movem.l    RegsAll,-(sp)
  12563.         move.l    _IntuitionBase(a4),a6
  12564.         move.l    ib_ActiveWindow(a6),d0
  12565.         beq.s    .End
  12566.         move.l    d0,a0                ; Get window
  12567.         move.l    wd_Flags(a0),d0
  12568.         and.l    #WFLG_SIZEGADGET,d0
  12569.         beq.s    .End
  12570.         move.w    wd_LeftEdge(a0),d0
  12571.         move.w    wd_TopEdge(a0),d1
  12572.         move.l    wd_WScreen(a0),a1
  12573.         move.w    sc_Width(a1),d2
  12574.         move.w    sc_Height(a1),d3
  12575.         neg.w    d0
  12576.         neg.w    d1
  12577.         DOLIB    ChangeWindowBox
  12578. .End        movem.l    (sp)+,RegsAll
  12579.         rts
  12580.  
  12581.  
  12582.  
  12583. **********************************************************************
  12584. *                   FKey-Command : Zip a window                      *
  12585. **********************************************************************
  12586. ZipWin        movem.l    RegsAll,-(sp)
  12587.         move.l    _IntuitionBase(a4),a6
  12588.         move.l    ib_ActiveWindow(a6),d0
  12589.         beq.s    .End
  12590.         move.l    d0,a0                ; Get window
  12591.         move.l    wd_Flags(a0),d0
  12592.         and.l    #WFLG_HASZOOM,d0
  12593.         beq.s    .End
  12594.         DOLIB    ZipWindow
  12595. .End        movem.l    (sp)+,RegsAll
  12596.         rts
  12597.  
  12598.  
  12599.  
  12600.  
  12601.  
  12602.  
  12603. **********************************************************************
  12604. *               Give visual feedback for button press                *
  12605. * D0 = Number of gadget                                              *
  12606. * A0 = Pointer to first gadget                                       *
  12607. * A5 = Pointer to window                                             *
  12608. **********************************************************************
  12609. ButtonCheck    movem.l    RegsAll,-(sp)
  12610.         move.l    a5,d1
  12611.         beq    .End
  12612.         RELLIB    GetGadgetPtr,_KCXBase
  12613.         move.l    a0,a3
  12614.         move.l    a0,a1
  12615.         or.w    #GFLG_SELECTED,gg_Flags(a3)    ; Set new state of gadget
  12616.         move.l    a3,a0
  12617.         move.l    a5,a1
  12618.         sub.l    a2,a2
  12619.         moveq    #1,d0
  12620.         RELLIB    RefreshGList,_IntuitionBase
  12621.         move.l    wd_IDCMPFlags(a5),d5        ; Only allow RAWKEYS
  12622.         move.l    a5,a0
  12623.         move.l    #IDCMP_RAWKEY,d0
  12624.         DOLIB    ModifyIDCMP
  12625. .WaitMsg    move.l    wd_UserPort(a5),a0        ; wait for release msg
  12626.         CALLSYS    WaitPort
  12627. .LoopMsgs    move.l    wd_UserPort(a5),a0
  12628.         RELLIB    GT_GetIMsg,_GadToolsBase
  12629.         tst.l    d0
  12630.         beq.s    .WaitMsg
  12631.         move.l    d0,a1
  12632.         move.l    im_Class(a1),d6
  12633.         move.w    im_Code(a1),d7
  12634.         DOLIB    GT_ReplyIMsg
  12635.         cmp.l    #IDCMP_RAWKEY,d6
  12636.         bne.s    .LoopMsgs
  12637.         and.w    #IECODE_UP_PREFIX,d7
  12638.         beq.s    .LoopMsgs
  12639.         move.l    a5,a0                ; reset idcmp-flags
  12640.         move.l    d5,d0
  12641.         RELLIB    ModifyIDCMP,_IntuitionBase
  12642.         and.w    #~GFLG_SELECTED,gg_Flags(a3)    ; Restore gadget image
  12643.         move.l    a3,a0
  12644.         move.l    a5,a1
  12645.         sub.l    a2,a2
  12646.         moveq    #1,d0
  12647.         DOLIB    RefreshGList
  12648. .End        movem.l    (sp)+,RegsAll
  12649.         rts
  12650.  
  12651.  
  12652.  
  12653. **********************************************************************
  12654. *          Convert a char to uppercase using Locale or Util          *
  12655. **********************************************************************
  12656. GetUpperCase    movem.l    d1-d7/a0-a6,-(sp)        ; Convert a char to upper case
  12657.         move.l    ZeroBase(pc),a4
  12658.         cmp.l    #48,d0
  12659.         blt.s    .NormChar
  12660.         cmp.l    #57,d0
  12661.         bgt.s    .NormChar
  12662.         lea    ConvTable(pc),a0
  12663.         sub.w    #48,d0
  12664.         moveq    #0,d1
  12665.         move.b    0(a0,d0),d1
  12666.         move.l    d1,d0
  12667. .NormChar    tst.l    MyLocale
  12668.         beq.s    .UseUtil
  12669.         move.l    MyLocale,a0            ; Using Locale
  12670.         RELLIB    ConvToUpper,_LocaleBase
  12671.         bra.s    .End
  12672. .UseUtil    RELLIB    ToUpper,_UtilityBase        ; or utility.library
  12673. .End        movem.l    (sp)+,d1-d7/a0-a6
  12674.         rts
  12675. ConvTable    dc.b    "=","!",'"',"§","$","%","&","/","(",")"
  12676.         EVEN
  12677.  
  12678.  
  12679.  
  12680. **********************************************************************
  12681. *                             Variables                              *
  12682. **********************************************************************
  12683. _SysBase    dc.l    0
  12684. _CxBase        dc.l    0
  12685. StrEditHook    ds.b    h_SIZEOF
  12686. FalseStr    dc.b    "0",0
  12687. TrueStr        dc.b    "1",0
  12688.         EVEN
  12689. CheckerName    dc.b    "KCOMM.CHECKER-PROCESS",0
  12690. RexxName    dc.b    "KCOMM.REXX-PROCESS",0
  12691.         EVEN
  12692.  
  12693.  
  12694.  
  12695.  
  12696. **********************************************************************
  12697. *                            Audio-Stuff                             *
  12698. **********************************************************************
  12699. LEFTCH0        EQU    2
  12700. RIGHTCH0    EQU    1
  12701. LEFTCH1        EQU    4
  12702. RIGHTCH1    EQU    8
  12703. AnyChannel    dc.b    LEFTCH0|RIGHTCH0
  12704.         dc.b    LEFTCH0|RIGHTCH1
  12705.         dc.b    LEFTCH1|RIGHTCH0
  12706.         dc.b    LEFTCH1|RIGHTCH1
  12707.  
  12708.  
  12709.  
  12710. **********************************************************************
  12711. *           Main format-definition for the Revision Header           *
  12712. **********************************************************************
  12713. CHeader        dc.b    "/* $Revision Header built automatically *************** (do not edit) ************",$0a
  12714. CLineNL        dc.b    "**",$0a,0
  12715. CLine        dc.b    "**     ",0,0
  12716. CCopyRight    dc.b    "** © Copyright by %s",$0a
  12717. CCR1        dc.b    "**",$0a,0
  12718. CFile        dc.b    "** File             : %s",$0a,0
  12719. CCreatedOn    dc.b    "** Created on       : %s, %s %s",$0a,0
  12720. CAuthor        dc.b    "** Created by       : %s",$0a,0
  12721. CRevision    dc.b    "** Current revision : V%d.%d",$0a,0
  12722. CPurpose    dc.b    "**",$0a
  12723. CP1        dc.b    "**",$0a
  12724. CP2        dc.b    "** Purpose",$0a
  12725. CP3        dc.b    "** -------",$0a,0
  12726. CLog        dc.b    "**",$0a
  12727. CL1        dc.b    "** Revision V%d.%d",$0a
  12728. CL2        dc.b    "** --------------",$0a
  12729. CL3        dc.b    "** created on %s, %s %s  by  %s.   LogMessage :",$0a,0
  12730. CLogInit    dc.b    "**",$0a
  12731. CLI1        dc.b    "** Revision V%d.%d",$0a
  12732. CLI2        dc.b    "** --------------",$0a
  12733. CLI3        dc.b    "** created on %s, %s %s  by  %s.   LogMessage :",$0a
  12734. CLI4        dc.b    "**     --- Initial release ---",$0a
  12735. CLI5        dc.b    "**",$0a
  12736. CEnd        dc.b    "*********************************************************************************/",$0a,0
  12737. CNewLog        dc.b    "**  -*-  changed on %s, %s %s  by  %s.   LogMessage :",$0a,0
  12738.         EVEN
  12739.  
  12740.  
  12741. **********************************************************************
  12742. *                           Defines for C                            *
  12743. **********************************************************************
  12744. CRevDefine1    dc.b    '#define REVISION "%d.%d"',$0a
  12745.         dc.b    '#define REVDATE  "%s"',$0a
  12746.         dc.b    '#define REVTIME  "%s"',$0a
  12747.         dc.b    '#define AUTHOR   "%s"',$0a
  12748.         dc.b    '#define VERNUM   %d',$0a
  12749.         dc.b    '#define REVNUM   %d',$0a,0
  12750.         EVEN
  12751.  
  12752.  
  12753. **********************************************************************
  12754. *                        Macros for Assembler                        *
  12755. **********************************************************************
  12756. AsmRevDefine1    dc.b    "REVISION  MACRO",$0a
  12757.         dc.b    '          dc.b "%d.%d"',$0a
  12758.         dc.b    "          ENDM",$0a
  12759.         dc.b    "REVDATE   MACRO",$0a
  12760.         dc.b    '          dc.b "%s"',$0a
  12761.         dc.b    "          ENDM",$0a
  12762.         dc.b    "REVTIME   MACRO",$0a
  12763.         dc.b    '          dc.b "%s"',$0a
  12764.         dc.b    "          ENDM",$0a
  12765.         dc.b    "AUTHOR    MACRO",$0a
  12766.         dc.b    '          dc.b "%s"',$0a
  12767.         dc.b    "          ENDM",$0a
  12768.         dc.b    "VERNUM    EQU  %d",$0a
  12769.         dc.b    "REVNUM    EQU  %d",$0a,0
  12770.         EVEN
  12771.  
  12772.  
  12773. **********************************************************************
  12774. *                    Constants for Pascal/Modula                     *
  12775. **********************************************************************
  12776. PASRevDefine1    dc.b    "CONST {* Place all your constants beneith these ones *}",$0a
  12777.         dc.b    '        REVISION = "%d.%d"',$0a
  12778.         dc.b    '         REVDATE = "%s"',$0a
  12779.         dc.b    '         REVTIME = "%s"',$0a
  12780.         dc.b    '          AUTHOR = "%s"',$0a
  12781.         dc.b    '          VERNUM = %d',$0a
  12782.         dc.b    '          REVNUM = %d',$0a,0
  12783.         EVEN
  12784.  
  12785.  
  12786.  
  12787. **********************************************************************
  12788. *                         Strings for Basic                          *
  12789. **********************************************************************
  12790. BASRevDefine1    dc.b    'REVISION$ = "%d.%d"',$0a
  12791.         dc.b    'REVDATE$ = "%s"',$0a
  12792.         dc.b    'REVTIME$ = "%s"',$0a
  12793.         dc.b    'AUTHOR$ = "%s"',$0a
  12794.         dc.b    'VERNUM = %d',$0a
  12795.         dc.b    'REVNUM = %d',$0a,0
  12796.         EVEN
  12797.  
  12798.  
  12799.  
  12800. **********************************************************************
  12801. *                   Datablock for Revision Header                    *
  12802. **********************************************************************
  12803. RevDefine    dc.l    0
  12804. RevCompanyDat    dc.l    Company
  12805. RevFileDat    dc.l    FileName
  12806. RevRevisionDat    dc.w    0
  12807.         dc.w    0
  12808. RevCreatedOnDat    dc.l    RevDayString
  12809.         dc.l    RevDateString
  12810.         dc.l    RevTimeString
  12811. RevAuthorDat    dc.l    Author
  12812. RevDefineDat    dc.w    0
  12813.         dc.w    0
  12814.         dc.l    RevDateString
  12815.         dc.l    RevTimeString
  12816.         dc.l    Author
  12817. RevVersionDat    dc.w    0
  12818.         dc.w    0
  12819. DefaultName    dc.b    "--- Unknown ---",0
  12820.         EVEN
  12821. Author        ds.b    42
  12822. Company        ds.b    42
  12823. RevDayString    ds.b    LEN_DATSTRING
  12824. RevDateString    ds.b    LEN_DATSTRING
  12825. RevTimeString    ds.b    LEN_DATSTRING
  12826. FileName    ds.b    256
  12827.  
  12828.  
  12829.  
  12830. **********************************************************************
  12831. *                   Formats for displaying the day                   *
  12832. **********************************************************************
  12833. FormatData    dc.l    DayString
  12834.         dc.l    DateString
  12835.         dc.l    TimeString
  12836. DayString    ds.b    LEN_DATSTRING
  12837. DateString    ds.b    LEN_DATSTRING
  12838. TimeString    ds.b    LEN_DATSTRING
  12839. OnlineString    ds.b    LEN_DATSTRING
  12840. AllDayString    ds.b    LEN_DATSTRING
  12841. AllDateString    ds.b    LEN_DATSTRING
  12842. AllTimeString    ds.b    LEN_DATSTRING
  12843. CopyTime    ds.b    LEN_DATSTRING
  12844. LogInDate    ds.b    LEN_DATSTRING
  12845. LogInTime    ds.b    LEN_DATSTRING
  12846.  
  12847.  
  12848. **********************************************************************
  12849. *               The main structure of all...The Broker               *
  12850. **********************************************************************
  12851.         CNOP    0,4
  12852. MyBrokerDef    dc.b    NB_VERSION            ; Commodities-Version (NEEDED)
  12853.         dc.b    0
  12854.         dc.l    BrokerName            ; Name of broker (For Exchange-Prg)
  12855.         dc.l    0                ; Title   (For Exchange-Prg)
  12856.         dc.l    0                ; Broker-Description (For Exchange-Prg)
  12857.         dc.w    NBU_NOTIFY!NBU_UNIQUE        ; Notify broker, we are unique
  12858.         dc.w    COF_SHOW_HIDE            ; We can be hidden/shown
  12859.         dc.w    0                ; Pri of broker plus an alignment byte
  12860.         dc.l    0                ; Port-Pointer
  12861.         dc.w    0                ; Dummy
  12862. BrokerName    dc.b    "KCommodity",0
  12863.         EVEN
  12864.  
  12865.  
  12866. **********************************************************************
  12867. *                         AutoRequester-Texts                        *
  12868. **********************************************************************
  12869. Only20ITxt    dc.b    0,1
  12870.         dc.b    RP_JAM1
  12871.         dc.b    0
  12872.         dc.w    10,10
  12873.         dc.l    0
  12874.         dc.l    Only20Txt
  12875.         dc.l    0
  12876. Only20Txt    dc.b    "KCommodity V"
  12877.         REVISION
  12878.         dc.b    " still only runs under OS 2.x !",$0a,0
  12879. Only20TxtEnd
  12880.         EVEN
  12881. OkITxt        dc.b    2,1
  12882.         dc.b    RP_JAM1
  12883.         dc.b    0
  12884.         dc.w    6,3
  12885.         dc.l    0
  12886.         dc.l    OkTxt
  12887.         dc.l    0
  12888. OkTxt        dc.b    "OK",0
  12889.         EVEN
  12890.  
  12891.  
  12892. **********************************************************************
  12893. *                            Error-Texts                             *
  12894. **********************************************************************
  12895. EasyTitle    dc.b    "KCommodity V"
  12896. VersionStr    REVISION
  12897.         dc.b    0
  12898.         EVEN
  12899.  
  12900.  
  12901. **********************************************************************
  12902. *                       Easy-Requeststructure                        *
  12903. **********************************************************************
  12904. MyEasyRequest    dc.l    es_SIZEOF
  12905.         dc.l    0
  12906.         dc.l    0
  12907.         dc.l    0
  12908.         dc.l    0
  12909. EasyGadget    dc.b    "OK",0
  12910.         EVEN
  12911.  
  12912.  
  12913. **********************************************************************
  12914. *                 Some defines fo easy customization                 *
  12915. **********************************************************************
  12916. PROGWINWIDTH    EQU    309
  12917. CLOCKWINIDCMP    EQU    IDCMP_CHANGEWINDOW|IDCMP_CLOSEWINDOW
  12918. CLOCKWINFLAGS    EQU    WFLG_CLOSEGADGET|WFLG_DEPTHGADGET|WFLG_DRAGBAR|WFLG_RMBTRAP
  12919.  
  12920.  
  12921.  
  12922. **********************************************************************
  12923. *                   Settings for Formatter window                    *
  12924. **********************************************************************
  12925. FormWinWindowTags:
  12926. FormWinL:
  12927.     DC.L    WA_Left,0
  12928. FormWinT:
  12929.     DC.L    WA_Top,0
  12930. FormWinW:
  12931.     DC.L    WA_Width,0
  12932. FormWinH:
  12933.     DC.L    WA_Height,0
  12934.     DC.L    WA_IDCMP,CYCLEIDCMP!STRINGIDCMP!CHECKBOXIDCMP!BUTTONIDCMP!IDCMP_CLOSEWINDOW!IDCMP_VANILLAKEY!IDCMP_CHANGEWINDOW
  12935.     DC.L    WA_Flags,WFLG_DRAGBAR!WFLG_DEPTHGADGET!WFLG_CLOSEGADGET!WFLG_SMART_REFRESH!WFLG_ACTIVATE
  12936. FormWinWG:
  12937.     DC.L    WA_Gadgets,0
  12938.     DC.L    WA_Title,FormTitle
  12939.     DC.L    WA_ScreenTitle,WindowScrTitle
  12940. FormWinSC:
  12941.     DC.L    WA_PubScreen,0
  12942.     DC.L    TAG_DONE
  12943.  
  12944.  
  12945. FormWinGTypes:
  12946.     DC.W    CYCLE_KIND
  12947.     DC.W    STRING_KIND
  12948.     DC.W    CHECKBOX_KIND
  12949.     DC.W    CHECKBOX_KIND
  12950.     DC.W    CHECKBOX_KIND
  12951.     DC.W    CHECKBOX_KIND
  12952.     DC.W    CHECKBOX_KIND
  12953.     DC.W    CHECKBOX_KIND
  12954.     DC.W    BUTTON_KIND
  12955.     DC.W    BUTTON_KIND
  12956.     DC.W    CHECKBOX_KIND
  12957.     DC.W    CHECKBOX_KIND
  12958.     DC.W    CHECKBOX_KIND
  12959.     DC.W    CHECKBOX_KIND
  12960.     DC.W    CHECKBOX_KIND
  12961.     DC.W    CHECKBOX_KIND
  12962.     DC.W    CHECKBOX_KIND
  12963.  
  12964. FormWinNGads:
  12965.     DC.W    106,3,69,13
  12966.     DC.L    DriveText,0
  12967.     DC.W    GD_Drive
  12968.     DC.L    PLACETEXT_LEFT,0,0
  12969.     DC.W    177,3,235,13
  12970.     DC.L    LabelText,0
  12971.     DC.W    GD_Label
  12972.     DC.L    PLACETEXT_RIGHT,0,0
  12973.     DC.W    152,23,26,11
  12974.     DC.L    TrashcanText,0
  12975.     DC.W    GD_Trashcan
  12976.     DC.L    PLACETEXT_LEFT,0,0
  12977.     DC.W    298,23,26,11
  12978.     DC.L    QuickText,0
  12979.     DC.W    GD_Quick
  12980.     DC.L    PLACETEXT_LEFT,0,0
  12981.     DC.W    473,23,26,11
  12982.     DC.L    FFSText,0
  12983.     DC.W    GD_FFS
  12984.     DC.L    PLACETEXT_LEFT,0,0
  12985.     DC.W    152,51,26,11
  12986.     DC.L    NoVerifyText,0
  12987.     DC.W    GD_NoVerify
  12988.     DC.L    PLACETEXT_LEFT,0,0
  12989.     DC.W    298,51,26,11
  12990.     DC.L    InstallText,0
  12991.     DC.W    GD_Install
  12992.     DC.L    PLACETEXT_LEFT,0,0
  12993.     DC.W    473,51,26,11
  12994.     DC.L    EjectText,0
  12995.     DC.W    GD_Eject
  12996.     DC.L    PLACETEXT_LEFT,0,0
  12997.     DC.W    5,85,104,12
  12998.     DC.L    FormOkText,0
  12999.     DC.W    GD_FormOk
  13000.     DC.L    PLACETEXT_IN,0,0
  13001.     DC.W    395,85,104,12
  13002.     DC.L    FormCancelText,0
  13003.     DC.W    GD_FormCancel
  13004.     DC.L    PLACETEXT_IN,0,0
  13005.     DC.W    152,71,26,11
  13006.     DC.L    WatchDisksText,0
  13007.     DC.W    GD_WatchDisks
  13008.     DC.L    PLACETEXT_LEFT,0,0
  13009.     DC.W    231,71,26,11
  13010.     DC.L    WatchTxt1,0
  13011.     DC.W    GD_Watch0
  13012.     DC.L    PLACETEXT_LEFT,0,0
  13013.     DC.W    313,71,26,11
  13014.     DC.L    WatchTxt2,0
  13015.     DC.W    GD_Watch1
  13016.     DC.L    PLACETEXT_LEFT,0,0
  13017.     DC.W    392,71,26,11
  13018.     DC.L    WatchTxt3,0
  13019.     DC.W    GD_Watch2
  13020.     DC.L    PLACETEXT_LEFT,0,0
  13021.     DC.W    473,71,26,11
  13022.     DC.L    WatchTxt4,0
  13023.     DC.W    GD_Watch3
  13024.     DC.L    PLACETEXT_LEFT,0,0
  13025.     DC.W    152,37,26,11
  13026.     DC.L    DiskCacheText,0
  13027.     DC.W    GD_DiskCache
  13028.     DC.L    PLACETEXT_LEFT,0,0
  13029.     DC.W    473,37,26,11
  13030.     DC.L    IntModeText,0
  13031.     DC.W    GD_IntMode
  13032.     DC.L    PLACETEXT_LEFT,0,0
  13033.  
  13034. FormWinGTags:
  13035. Zero2    DC.L    GTCY_Labels,DriveList
  13036.     DC.L    GT_Underscore,'_'
  13037.     DC.L    TAG_DONE
  13038.     DC.L    GTST_EditHook,StrEditHook
  13039.     DC.L    STRINGA_ExitHelp,1
  13040.     DC.L    GTST_MaxChars,256
  13041.     DC.L    GT_Underscore,'_'
  13042.     DC.L    TAG_DONE
  13043.     DC.L    GTCB_Scaled,-1
  13044.     DC.L    GT_Underscore,'_'
  13045.     DC.L    TAG_DONE
  13046.     DC.L    GTCB_Scaled,-1
  13047.     DC.L    GT_Underscore,'_'
  13048.     DC.L    TAG_DONE
  13049.     DC.L    GTCB_Scaled,-1
  13050.     DC.L    GT_Underscore,'_'
  13051.     DC.L    TAG_DONE
  13052.     DC.L    GTCB_Scaled,-1
  13053.     DC.L    GT_Underscore,'_'
  13054.     DC.L    TAG_DONE
  13055.     DC.L    GTCB_Scaled,-1
  13056.     DC.L    GT_Underscore,'_'
  13057.     DC.L    TAG_DONE
  13058.     DC.L    GTCB_Scaled,-1
  13059.     DC.L    GT_Underscore,'_'
  13060.     DC.L    TAG_DONE
  13061.     DC.L    GT_Underscore,'_'
  13062.     DC.L    TAG_DONE
  13063.     DC.L    GT_Underscore,'_'
  13064.     DC.L    TAG_DONE
  13065.     DC.L    GTCB_Scaled,-1
  13066.     DC.L    GT_Underscore,'_'
  13067.     DC.L    TAG_DONE
  13068. WatchGads
  13069.     DC.L    GA_Disabled,1
  13070.     DC.L    GTCB_Scaled,-1
  13071.     DC.L    GT_Underscore,'_'
  13072.     DC.L    TAG_DONE
  13073.     DC.L    GA_Disabled,1
  13074.     DC.L    GTCB_Scaled,-1
  13075.     DC.L    GT_Underscore,'_'
  13076.     DC.L    TAG_DONE
  13077.     DC.L    GA_Disabled,1
  13078.     DC.L    GTCB_Scaled,-1
  13079.     DC.L    GT_Underscore,'_'
  13080.     DC.L    TAG_DONE
  13081.     DC.L    GA_Disabled,1
  13082.     DC.L    GTCB_Scaled,-1
  13083.     DC.L    GT_Underscore,'_'
  13084.     DC.L    TAG_DONE
  13085.     DC.L    GTCB_Scaled,-1
  13086.     DC.L    GT_Underscore,'_'
  13087.     DC.L    TAG_DONE
  13088.     DC.L    GTCB_Scaled,-1
  13089.     DC.L    GT_Underscore,'_'
  13090.     DC.L    TAG_DONE
  13091.  
  13092.  
  13093.  
  13094. GD_Drive                               EQU    0
  13095. GD_Label                               EQU    1
  13096. GD_Trashcan                            EQU    2
  13097. GD_Quick                               EQU    3
  13098. GD_FFS                                 EQU    4
  13099. GD_NoVerify                            EQU    5
  13100. GD_Install                             EQU    6
  13101. GD_Eject                               EQU    7
  13102. GD_FormOk                              EQU    8
  13103. GD_FormCancel                          EQU    9
  13104. GD_WatchDisks                          EQU    10
  13105. GD_Watch0                              EQU    11
  13106. GD_Watch1                              EQU    12
  13107. GD_Watch2                              EQU    13
  13108. GD_Watch3                              EQU    14
  13109. GD_DiskCache                           EQU    15
  13110. GD_IntMode                             EQU    16
  13111.  
  13112.  
  13113.  
  13114.  
  13115. **********************************************************************
  13116. *                      Settings for bill window                      *
  13117. **********************************************************************
  13118.  
  13119. BillWinWindowTags:
  13120. BillWinL:
  13121.     DC.L    WA_Left,0
  13122. BillWinT:
  13123.     DC.L    WA_Top,0
  13124. BillWinW:
  13125.     DC.L    WA_Width,0
  13126. BillWinH:
  13127.     DC.L    WA_Height,0
  13128.     DC.L    WA_IDCMP,TEXTIDCMP!MXIDCMP!CHECKBOXIDCMP!IDCMP_CLOSEWINDOW!IDCMP_VANILLAKEY!IDCMP_CHANGEWINDOW
  13129. BillWinF:
  13130.     DC.L    WA_Flags,WFLG_DRAGBAR!WFLG_DEPTHGADGET!WFLG_CLOSEGADGET!WFLG_SMART_REFRESH
  13131. BillWinWG:
  13132.     DC.L    WA_Gadgets,0
  13133.     DC.L    WA_Title,BillTitle
  13134.     DC.L    WA_ScreenTitle,WindowScrTitle
  13135. BillWinSC:
  13136.     DC.L    WA_PubScreen,0
  13137. Zero4    DC.L    WA_Zoom,BillZoomSize
  13138.     DC.L    TAG_DONE
  13139.  
  13140.  
  13141. BillWinGTypes:
  13142.     DC.W    TEXT_KIND
  13143.     DC.W    TEXT_KIND
  13144.     DC.W    TEXT_KIND
  13145.     DC.W    MX_KIND
  13146.     DC.W    MX_KIND
  13147.     DC.W    TEXT_KIND
  13148.     DC.W    CHECKBOX_KIND
  13149.     DC.W    BUTTON_KIND
  13150.     DC.W    BUTTON_KIND
  13151.  
  13152. BillWinNGads:
  13153.     DC.W    7,13,72,13
  13154.     DC.L    BillTimeText,0
  13155.     DC.W    GD_BillTime
  13156.     DC.L    PLACETEXT_ABOVE,0,0
  13157.     DC.W    125,13,72,13
  13158.     DC.L    BillOnlineText,0
  13159.     DC.W    GD_BillOnline
  13160.     DC.L    PLACETEXT_ABOVE,0,0
  13161.     DC.W    241,13,72,13
  13162.     DC.L    BillCostText,0
  13163.     DC.W    GD_BillCost
  13164.     DC.L    PLACETEXT_ABOVE,0,0
  13165.     DC.W    7,30,17,9
  13166.     DC.L    0,0
  13167.     DC.W    GD_BillTimeMX
  13168.     DC.L    PLACETEXT_RIGHT,0,0
  13169.     DC.W    296,30,17,9
  13170.     DC.L    0,0
  13171.     DC.W    GD_BillCheap
  13172.     DC.L    PLACETEXT_LEFT,0,0
  13173.     DC.W    6,73,305,13
  13174.     DC.L    0,0
  13175.     DC.W    GD_BillHour
  13176.     DC.L    0,0,0
  13177.     DC.W    6,89,26,11
  13178.     DC.L    LogCallText,0
  13179.     DC.W    GD_LogCall
  13180.     DC.L    PLACETEXT_RIGHT,0,0
  13181.     DC.W    125,30,72,13
  13182.     DC.L    BillStartText,0
  13183.     DC.W    GD_BillStart
  13184.     DC.L    PLACETEXT_IN,0,0
  13185.     DC.W    125,47,72,13
  13186.     DC.L    BillStopText,0
  13187.     DC.W    GD_BillStop
  13188.     DC.L    PLACETEXT_IN,0,0
  13189.  
  13190. BillWinGTags:
  13191.     DC.L    GTTX_Text,TimeString
  13192.     DC.L    GTTX_Border,1
  13193.     DC.L    TAG_DONE
  13194.     DC.L    GTTX_Text,OnlineString
  13195.     DC.L    GTTX_Border,1
  13196.     DC.L    TAG_DONE
  13197.     DC.L    GTTX_Text,CostString
  13198.     DC.L    GTTX_Border,1
  13199.     DC.L    TAG_DONE
  13200.     DC.L    GTMX_Scaled,-1
  13201.     DC.L    GTMX_Labels,BillTimeMXLabels
  13202.     DC.L    GTMX_Spacing,2
  13203.     DC.L    GT_Underscore,'_'
  13204.     DC.L    TAG_DONE
  13205.     DC.L    GTMX_Scaled,-1
  13206.     DC.L    GTMX_Labels,BillCheapLabels
  13207.     DC.L    GTMX_Spacing,2
  13208.     DC.L    GT_Underscore,'_'
  13209.     DC.L    TAG_DONE
  13210.     DC.L    GTTX_Border,1
  13211.     DC.L    TAG_DONE
  13212.     DC.L    GTCB_Scaled,-1
  13213.     DC.L    GT_Underscore,'_'
  13214.     DC.L    TAG_DONE
  13215.     DC.L    GT_Underscore,'_'
  13216.     DC.L    TAG_DONE
  13217.     DC.L    GT_Underscore,'_'
  13218.     DC.L    TAG_DONE
  13219.  
  13220.  
  13221. BillTimeMXTags:
  13222.     DC.L    GTMX_Labels,BillTimeMXLabels
  13223.     DC.L    GTMX_Spacing,2
  13224.     DC.L    GT_Underscore,'_'
  13225.     DC.L    TAG_DONE
  13226. BillCheapTags:
  13227.     DC.L    GTMX_Labels,BillCheapLabels
  13228.     DC.L    GTMX_Spacing,2
  13229.     DC.L    GT_Underscore,'_'
  13230.     DC.L    TAG_DONE
  13231. BillTimeMXLabels:
  13232.     DC.L    BillTimeMXLab0
  13233.     DC.L    BillTimeMXLab1
  13234.     DC.L    BillTimeMXLab2
  13235.     DC.L    0
  13236. BillCheapLabels:
  13237.     DC.L    BillCheapLab0
  13238.     DC.L    BillCheapLab1
  13239.     DC.L    0
  13240.  
  13241.  
  13242. GD_BillTime                            EQU    0
  13243. GD_BillOnline                          EQU    1
  13244. GD_BillCost                            EQU    2
  13245. GD_BillTimeMX                          EQU    3
  13246. GD_BillCheap                           EQU    4
  13247. GD_BillHour                            EQU    5
  13248. GD_LogCall                             EQU    6
  13249. GD_BillStart                           EQU    7
  13250. GD_BillStop                            EQU    8
  13251.  
  13252. KD_BillTime1    EQU    '1'
  13253. KD_BillTime2    EQU    '2'
  13254. KD_BillTime3    EQU    '3'
  13255. KD_BillNormal    EQU    '4'
  13256. KD_BillCheap    EQU    '5'
  13257.  
  13258.  
  13259.  
  13260. **********************************************************************
  13261. *                      Settings for Log window                       *
  13262. **********************************************************************
  13263. LogWinWindowTags:
  13264. LogWinL:
  13265.     DC.L    WA_Left,0
  13266. LogWinT:
  13267.     DC.L    WA_Top,0
  13268. LogWinW:
  13269.     DC.L    WA_Width,0
  13270. LogWinH:
  13271.     DC.L    WA_Height,0
  13272.     DC.L    WA_IDCMP,STRINGIDCMP!BUTTONIDCMP!INTEGERIDCMP!IDCMP_CLOSEWINDOW!IDCMP_ACTIVEWINDOW!IDCMP_VANILLAKEY!IDCMP_CHANGEWINDOW!IDCMP_REFRESHWINDOW
  13273.     DC.L    WA_Flags,WFLG_DRAGBAR!WFLG_DEPTHGADGET!WFLG_CLOSEGADGET!WFLG_SMART_REFRESH!WFLG_ACTIVATE
  13274. LogWinWG:
  13275.     DC.L    WA_Gadgets,0
  13276.     DC.L    WA_ScreenTitle,WindowScrTitle
  13277. LogWinSC:
  13278.     DC.L    WA_PubScreen,0
  13279.     DC.L    TAG_DONE
  13280.  
  13281.  
  13282. LogWinGTypes:
  13283.     DC.W    STRING_KIND
  13284.     DC.W    STRING_KIND
  13285.     DC.W    STRING_KIND
  13286.     DC.W    STRING_KIND
  13287.     DC.W    STRING_KIND
  13288.     DC.W    BUTTON_KIND
  13289.     DC.W    BUTTON_KIND
  13290.     DC.W    INTEGER_KIND
  13291.     DC.W    INTEGER_KIND
  13292.     DC.W    BUTTON_KIND
  13293.  
  13294. LogWinNGads:
  13295.     DC.W    5,4,502,14
  13296.     DC.L    0,0
  13297.     DC.W    GD_Line1
  13298.     DC.L    0,0,0
  13299.     DC.W    5,20,502,14
  13300.     DC.L    0,0
  13301.     DC.W    GD_Line2
  13302.     DC.L    0,0,0
  13303.     DC.W    5,36,502,14
  13304.     DC.L    0,0
  13305.     DC.W    GD_Line3
  13306.     DC.L    0,0,0
  13307.     DC.W    5,52,502,14
  13308.     DC.L    0,0
  13309.     DC.W    GD_Line4
  13310.     DC.L    0,0,0
  13311.     DC.W    5,68,502,14
  13312.     DC.L    0,0
  13313.     DC.W    GD_Line5
  13314.     DC.L    0,0,0
  13315.     DC.W    5,86,99,12
  13316.     DC.L    LogOkText,0
  13317.     DC.W    GD_LogOk
  13318.     DC.L    PLACETEXT_IN,0,0
  13319.     DC.W    408,86,99,12
  13320.     DC.L    LogCancelText,0
  13321.     DC.W    GD_LogCancel
  13322.     DC.L    PLACETEXT_IN,0,0
  13323.     DC.W    307,86,36,13
  13324.     DC.L    LogVerText,0
  13325.     DC.W    GD_LogVer
  13326.     DC.L    PLACETEXT_LEFT,0,0
  13327.     DC.W    366,86,36,13
  13328.     DC.L    LogRevText,0
  13329.     DC.W    GD_LogRev
  13330.     DC.L    PLACETEXT_LEFT,0,0
  13331.     DC.W    116,86,99,12
  13332.     DC.L    LogOnlyTextText,0
  13333.     DC.W    GD_LogOnlyText
  13334.     DC.L    PLACETEXT_IN,0,0
  13335.  
  13336. LogWinGTags:
  13337.     DC.L    GTST_EditHook,StrEditHook
  13338.     DC.L    STRINGA_ExitHelp,1
  13339.     DC.L    GTST_MaxChars,60
  13340.     DC.L    TAG_DONE
  13341.     DC.L    GTST_EditHook,StrEditHook
  13342.     DC.L    STRINGA_ExitHelp,1
  13343.     DC.L    GTST_MaxChars,60
  13344.     DC.L    TAG_DONE
  13345.     DC.L    GTST_EditHook,StrEditHook
  13346.     DC.L    STRINGA_ExitHelp,1
  13347.     DC.L    GTST_MaxChars,60
  13348.     DC.L    TAG_DONE
  13349.     DC.L    GTST_EditHook,StrEditHook
  13350.     DC.L    STRINGA_ExitHelp,1
  13351.     DC.L    GTST_MaxChars,60
  13352.     DC.L    TAG_DONE
  13353.     DC.L    GTST_EditHook,StrEditHook
  13354.     DC.L    STRINGA_ExitHelp,1
  13355.     DC.L    GTST_MaxChars,60
  13356.     DC.L    TAG_DONE
  13357.     DC.L    GT_Underscore,'_'
  13358.     DC.L    TAG_DONE
  13359.     DC.L    GT_Underscore,'_'
  13360.     DC.L    TAG_DONE
  13361.     DC.L    GTST_EditHook,StrEditHook
  13362.     DC.L    STRINGA_ExitHelp,1
  13363.     DC.L    GTIN_Number,0
  13364.     DC.L    GTIN_MaxChars,2
  13365.     DC.L    GT_Underscore,'_'
  13366.     DC.L    TAG_DONE
  13367.     DC.L    GTST_EditHook,StrEditHook
  13368.     DC.L    STRINGA_ExitHelp,1
  13369.     DC.L    GTIN_Number,0
  13370.     DC.L    GTIN_MaxChars,2
  13371.     DC.L    TAG_DONE
  13372.     DC.L    GT_Underscore,'_'
  13373.     DC.L    TAG_DONE
  13374. LogRevText:
  13375.     DC.B    '.',0
  13376.     CNOP    0,2
  13377.  
  13378. GD_Line1                               EQU    0
  13379. GD_Line2                               EQU    1
  13380. GD_Line3                               EQU    2
  13381. GD_Line4                               EQU    3
  13382. GD_Line5                               EQU    4
  13383. GD_LogOk                               EQU    5
  13384. GD_LogCancel                           EQU    6
  13385. GD_LogVer                              EQU    7
  13386. GD_LogRev                              EQU    8
  13387. GD_LogOnlyText                         EQU    9
  13388.  
  13389. KD_LogOk    EQU    'O'
  13390. KD_LogCancel    EQU    'C'
  13391. KD_LogVer    EQU    'R'
  13392.  
  13393.  
  13394.  
  13395.  
  13396. **********************************************************************
  13397. *                    Settings for Progress window                    *
  13398. **********************************************************************
  13399. ProgWinWindowTags:
  13400. ProgWinL:
  13401.     DC.L    WA_Left,0
  13402. ProgWinT:
  13403.     DC.L    WA_Top,0
  13404. ProgWinW:
  13405.     DC.L    WA_Width,0
  13406. ProgWinH:
  13407.     DC.L    WA_Height,0
  13408.     DC.L    WA_IDCMP,TEXTIDCMP
  13409.     DC.L    WA_Flags,WFLG_DRAGBAR!WFLG_SMART_REFRESH
  13410. ProgWinWG:
  13411.     DC.L    WA_Gadgets,0
  13412.     DC.L    WA_Title,ProgWinWTitle
  13413.     DC.L    WA_ScreenTitle,WindowScrTitle
  13414. ProgWinSC:
  13415.     DC.L    WA_PubScreen,0
  13416.     DC.L    TAG_DONE
  13417.  
  13418. ProgWinGTypes:
  13419.     DC.W    TEXT_KIND
  13420.     DC.W    TEXT_KIND
  13421.  
  13422. ProgWinNGads:
  13423.     DC.W    12,6,26,12
  13424.     DC.L    0,0
  13425.     DC.W    GD_Prog0
  13426.     DC.L    0,0,0
  13427.     DC.W    265,6,42,12
  13428.     DC.L    0,0
  13429.     DC.W    GD_Prog100
  13430.     DC.L    0,0,0
  13431.  
  13432. ProgWinGTags:
  13433.     DC.L    GTTX_Text,Prog0String
  13434.     DC.L    TAG_DONE
  13435.     DC.L    GTTX_Text,Prog100String
  13436.     DC.L    TAG_DONE
  13437.  
  13438. Prog0String:
  13439.     DC.B    '0%',0
  13440.     CNOP     0,2
  13441. Prog100String:
  13442.     DC.B    '100%',0
  13443.     CNOP     0,2
  13444.  
  13445. GD_Prog0                               EQU    0
  13446. GD_Prog100                             EQU    1
  13447. ProgWin_CNT        EQU 2
  13448.  
  13449.  
  13450.  
  13451. **********************************************************************
  13452. *                    Definitions for Clock-Window                    *
  13453. **********************************************************************
  13454. ClockWindowTags    dc.l    WA_Left
  13455. ClockLeft    dc.l    0
  13456.         dc.l    WA_Top
  13457. ClockTop    dc.l    0
  13458.         dc.l    WA_InnerWidth
  13459. ClockWidth    dc.l    0
  13460.         dc.l    WA_InnerHeight
  13461.         dc.l    0
  13462.         dc.l    WA_ScreenTitle
  13463.         dc.l    WindowScrTitle
  13464.         dc.l    WA_IDCMP
  13465.         dc.l    CLOCKWINIDCMP
  13466.         dc.l    WA_Flags
  13467.         dc.l    CLOCKWINFLAGS
  13468.         dc.l    WA_Title
  13469.         dc.l    0
  13470.         dc.l    TAG_DONE
  13471.  
  13472.  
  13473.  
  13474.  
  13475.  
  13476. **********************************************************************
  13477. *                Definitions for Select Screen window                *
  13478. **********************************************************************
  13479. SelScrWinWindowTags:
  13480. SelScrWinL:
  13481.     DC.L    WA_Left,0
  13482. SelScrWinT:
  13483.     DC.L    WA_Top,0
  13484. SelScrWinW:
  13485.     DC.L    WA_Width,0
  13486. SelScrWinH:
  13487.     DC.L    WA_Height,0
  13488.     DC.L    WA_IDCMP,LISTVIEWIDCMP!CYCLEIDCMP!BUTTONIDCMP!NUMBERIDCMP!TEXTIDCMP!IDCMP_CLOSEWINDOW!IDCMP_VANILLAKEY!IDCMP_CHANGEWINDOW!IDCMP_REFRESHWINDOW
  13489.     DC.L    WA_Flags,WFLG_DRAGBAR!WFLG_DEPTHGADGET!WFLG_CLOSEGADGET!WFLG_SMART_REFRESH!WFLG_ACTIVATE
  13490. SelScrWinWG:
  13491.     DC.L    WA_Gadgets,0
  13492.     DC.L    WA_Title,SelScrTitle
  13493.     DC.L    WA_ScreenTitle,WindowScrTitle
  13494. SelScrWinSC:
  13495.     DC.L    WA_PubScreen,0
  13496.     DC.L    TAG_DONE
  13497.  
  13498.  
  13499. SelScrWinGTypes:
  13500.     DC.W    LISTVIEW_KIND
  13501.     DC.W    BUTTON_KIND
  13502.     DC.W    BUTTON_KIND
  13503.     DC.W    NUMBER_KIND
  13504.     DC.W    TEXT_KIND
  13505.     DC.W    BUTTON_KIND
  13506.  
  13507. SelScrWinNGads:
  13508.     DC.W    9,13,242,84
  13509.     DC.L    TaskListText,0
  13510.     DC.W    GD_TaskList
  13511.     DC.L    PLACETEXT_ABOVE,0,0
  13512.     DC.W    256,86,93,12
  13513.     DC.L    SelScrActText,0
  13514.     DC.W    GD_SelScrAct
  13515.     DC.L    PLACETEXT_IN,0,0
  13516.     DC.W    353,86,93,12
  13517.     DC.L    SelScrCancelText,0
  13518.     DC.W    GD_SelScrCancel
  13519.     DC.L    PLACETEXT_IN,0,0
  13520.     DC.W    256,40,190,12
  13521.     DC.L    SelScrNumScrText,0
  13522.     DC.W    GD_SelScrNumScr
  13523.     DC.L    PLACETEXT_ABOVE,0,0
  13524.     DC.W    256,68,190,12
  13525.     DC.L    SelScrDefPubText,0
  13526.     DC.W    GD_SelScrDefPub
  13527.     DC.L    PLACETEXT_ABOVE,0,0
  13528.     DC.W    256,13,190,12
  13529.     DC.L    SelScrUpdateText,0
  13530.     DC.W    GD_SelScrUpdate
  13531.     DC.L    PLACETEXT_IN,0,0
  13532.  
  13533.  
  13534. SelScrWinGTags:
  13535.     DC.L    GTLV_Labels,0
  13536.     DC.L    GTLV_ShowSelected,0
  13537.     DC.L    GTLV_Selected,0
  13538.     DC.L    GT_Underscore,'_'
  13539.     DC.L    TAG_DONE
  13540.     DC.L    GT_Underscore,'_'
  13541.     DC.L    TAG_DONE
  13542.     DC.L    GT_Underscore,'_'
  13543.     DC.L    TAG_DONE
  13544. ScrNumTag
  13545.     DC.L    GTNM_Number,0
  13546.     DC.L    GTNM_Border,1
  13547.     DC.L    TAG_DONE
  13548.     DC.L    GTTX_Text,DefPubScreenName
  13549.     DC.L    GTTX_Border,1
  13550.     DC.L    TAG_DONE
  13551.     DC.L    GT_Underscore,'_'
  13552.     DC.L    TAG_DONE
  13553. DefPubScreenName    ds.b    MAXPUBSCREENNAME+1
  13554.  
  13555.  
  13556. GD_TaskList                            EQU    0
  13557. GD_SelScrAct                           EQU    1
  13558. GD_SelScrCancel                        EQU    2
  13559. GD_SelScrNumScr                        EQU    3
  13560. GD_SelScrDefPub                        EQU    4
  13561. GD_SelScrUpdate                        EQU    5
  13562.  
  13563. KD_TaskList        EQU    'L'
  13564. KD_SelScrAct        EQU    'A'
  13565. KD_SelScrCancel        EQU    'C'
  13566. KD_SelScrUpdate        EQU    'U'
  13567.  
  13568.  
  13569.  
  13570.  
  13571. **********************************************************************
  13572. *                    Standad string for the Costs                    *
  13573. **********************************************************************
  13574. CostString    dc.b    "    0.00",0
  13575. **********************************************************************
  13576. *              Definitions for userdefinable filenames               *
  13577. **********************************************************************
  13578. DirPrefsName    dc.b    "KCX.PREFS",0
  13579. EnvPrefsName    dc.b    "ENV:KCX/KCX.PREFS",0
  13580. EnvArcPrefsName    dc.b    "ENVARC:KCX/KCX.PREFS",0
  13581.         EVEN
  13582.  
  13583.  
  13584.  
  13585. **********************************************************************
  13586. *                         HotKey definitions                         *
  13587. **********************************************************************
  13588. DefaultHotKeys    dc.l    DefPopUpKey,DefBillHotKey,DefFormHotKey
  13589.         dc.l    DefPageHotKey,DefShellHotKey
  13590.         dc.l    DefUmlautHotKey,DefSnapHotKey,DefDoBlankHotKey
  13591.         dc.l    DefDumpHotKey,DefCenterHotKey,DefSelScrHotKey
  13592.         dc.l    DefClockHotKey,DefFKeyHotKey,DefSunHotKey
  13593. DefPopUpKey    dc.b    "LCOMMAND HELP",0
  13594. DefBillHotKey    dc.b    "ALT SHIFT B",0
  13595. DefFormHotKey    dc.b    "ALT SHIFT F",0
  13596. DefPageHotKey    dc.b    "RALT HELP",0
  13597. DefShellHotKey    dc.b    "ALT SHIFT S",0
  13598. DefUmlautHotKey    dc.b    "ALT SHIFT U",0
  13599. DefSnapHotKey    dc.b    "ALT SHIFT G",0
  13600. DefDoBlankHotKey    dc.b    "ALT SHIFT D",0
  13601. DefDumpHotKey    dc.b    "ALT NUMERICPAD *",0
  13602. DefCenterHotKey    dc.b    "ALT SHIFT X",0
  13603. DefSelScrHotKey    dc.b    "LSHIFT ESC",0
  13604. DefClockHotKey    dc.b    "ALT SHIFT C",0
  13605. DefFKeyHotKey    dc.b    "ALT SHIFT K",0
  13606. DefSunHotKey    dc.b    "ALT SHIFT M",0
  13607.         EVEN
  13608. POPUPKEYID    EQU    1            ; Definitions for IDs
  13609. BILLKEYID    EQU    2
  13610. FORMKEYID    EQU    3
  13611. PAGEKEYID    EQU    4
  13612. SHELLKEYID    EQU    5
  13613. UMLAUTKEYID    EQU    6
  13614. SNAPKEYID    EQU    7
  13615. DOBLANKKEYID    EQU    8
  13616. DUMPKEYID    EQU    9
  13617. CENTERKEYID    EQU    10
  13618. SELECTSCRKEYID    EQU    11
  13619. CLOCKKEYID    EQU    12
  13620. FKEYKEYID    EQU    13
  13621. SUNKEYID    EQU    14
  13622.  
  13623.  
  13624. **********************************************************************
  13625. *                     Defines for HotKey-Window                      *
  13626. **********************************************************************
  13627. HotKeyGadStat    dc.l    PopUpKey        ; CX_PopKey
  13628.         dc.l    BillHotKey        ; Bill
  13629.         dc.l    FormatHotKey        ; Formatter
  13630.         dc.l    PageHotKey        ; Page
  13631.         dc.l    ShellHotKey        ; UserShell
  13632.         dc.l    UmlautHotKey        ; Map Umlauts
  13633.         dc.l    SnapHotKey        ; Snap memory
  13634.         dc.l    DoBlankHotKey        ; Immediate Blank
  13635.         dc.l    DumpHotKey        ; Display dump
  13636.         dc.l    CenterHotKey        ; Center a screen
  13637.         dc.l    SelScrHotKey        ; Select Screen to pop up
  13638.         dc.l    ClockHotKey        ; On/Off clock
  13639.         dc.l    FKeyHotKey        ; On/Off FKeys
  13640.         dc.l    SunHotKey        ; On/Off SunMouse
  13641. HOTKEYNUM    EQU    ((*-HotKeyGadStat)/4)
  13642. HotKeyGadVars    dc.l    MainHandle,ControlTitle,PopUpFilter
  13643.         dc.l    BillHandle,BillTitle,BillFilter
  13644.         dc.l    FormHandle,FormTitle,FormFilter
  13645.         dc.l    0,0,PageFilter
  13646.         dc.l    0,0,ShellFilter
  13647.         dc.l    0,0,UmlautFilter
  13648.         dc.l    0,0,SnapFilter
  13649.         dc.l    0,0,DoBlankFilter
  13650.         dc.l    PrintHandle,PrintTitle,DumpFilter
  13651.         dc.l    0,0,CenterFilter
  13652.         dc.l    SelScrHandle,SelScrTitle,SelScrFilter
  13653.         dc.l    0,0,ClockFilter
  13654.         dc.l    0,0,FKeyFilter
  13655.         dc.l    0,0,SunFilter
  13656.  
  13657.  
  13658. **********************************************************************
  13659. *                      Variables for formatter                       *
  13660. **********************************************************************
  13661. DriveArg    dc.b    " DRIVE ",0
  13662. NameArg        dc.b    " NAME ",0
  13663. IconsArg    dc.b    " NOICONS",0
  13664. QuickArg    dc.b    " QUICK",0
  13665. FFSArg        dc.b    " FFS",0
  13666. VerifyArg    dc.b    " NOVERIFY",0
  13667. InstallArg    dc.b    " INSTALL",0
  13668. EjectArg    dc.b    " EJECT",0
  13669. DirCacheArg    dc.b    " DIRCACHE",0
  13670. IntModeArg    dc.b    " INTL",0
  13671.         EVEN
  13672.  
  13673.  
  13674. **********************************************************************
  13675. *                   Command definitions for FKeys                    *
  13676. **********************************************************************
  13677. FKeyCmds    dc.l    MinimizeCmd,MaximizeCmd,ZipWinCmd
  13678. FKEYCMDNUM    EQU    (*-FKeyCmds)/4
  13679. FKeyRouts    dc.l    MinimizeWin,MaximizeWin,ZipWin
  13680. MinimizeCmd    dc.b    "MINWIN",0
  13681. MaximizeCmd    dc.b    "MAXWIN",0
  13682. ZipWinCmd    dc.b    "ZIPWIN",0
  13683.         EVEN
  13684.  
  13685.  
  13686.  
  13687.  
  13688. **********************************************************************
  13689. *                 Text attr for the text in titlebar                 *
  13690. **********************************************************************
  13691. TxtAttr        dc.l    TxtAttrFont
  13692.         dc.w    0
  13693.         dc.b    FS_NORMAL
  13694.         dc.b    0
  13695.  
  13696.  
  13697.  
  13698. **********************************************************************
  13699. *                     Formatstrings for RawDoFmt                     *
  13700. **********************************************************************
  13701. TimeFormats    dc.l    FormLSec,FormLNSec,FormSSec,FormSNSec
  13702. FormLSec    dc.b    " %s %s %s ",0
  13703. FormLNSec    dc.b    " %s %s %.5s ",0
  13704. FormSSec    dc.b    " %.3s %s %s ",0
  13705. FormSNSec    dc.b    " %.3s %s %.5s ",0
  13706. CostFormString    dc.b    "%5ld.%02ld",0
  13707. PerHourForm    dc.b    "%4ld.%02ld",0
  13708. LIntFormat    dc.b    "%ld",0
  13709. StringFormat    dc.b    "%s",0
  13710. FormLongSStr    dc.b    "%02ld:%02ld:%02ld",0
  13711. FormLongNSStr    dc.b    "%02ld:%02ld",0
  13712. ScrDimmFormat    dc.b    "%2.2ld",0
  13713. FormMemString    dc.b    " C: %7ld   F: %8ld ",0
  13714. DoubleMemString    dc.b    "  C: %ld   F: %ld ",0
  13715. MousePosForm    dc.b    "  X: %4.4d  Y: %4.4d",0
  13716. ChipMem        dc.l    0
  13717. FastMem        dc.l    0
  13718. TotalMem    dc.l    0
  13719. NextUnit    dc.l    0
  13720. UnitsDone    dc.l    0
  13721. LogEntryDat    dc.l    LogInDate
  13722.         dc.l    LogInTime
  13723.         dc.l    AllTimeString
  13724. LogTimeZone    dc.l    0
  13725. LogEntryTariff    dc.w    0
  13726. OnlineHour    dc.l    0
  13727. OnlineMinute    dc.l    0
  13728. OnlineSeconds    dc.l    0
  13729. CostMajor    dc.l    0
  13730. CostMinor    dc.l    0
  13731. BillTotalCost    dc.l    0
  13732. BillDayCost    dc.l    0
  13733. BillDayPtr    dc.l    BillDayStr
  13734. BillMajor    dc.l    0
  13735. BillMinor    dc.l    0
  13736. BillDayStr    ds.b    10
  13737. ThisChip    dc.l    0
  13738. ThisFast    dc.l    0
  13739.  
  13740.  
  13741.  
  13742.  
  13743. **********************************************************************
  13744. *                          The AppIcon-Icon                          *
  13745. **********************************************************************
  13746. KCXAppIconDef    dc.w    0,0
  13747.         dc.l    0                ; Gadget structure
  13748.         dc.w    0,0
  13749. AppIconWidth    dc.w    0
  13750. AppIconHeight    dc.w    0
  13751.         dc.w    0,0,0
  13752. AppIconPic    dc.l    0
  13753.         dc.l    0,0,0,0
  13754.         dc.w    0
  13755.         dc.l    0
  13756.         dc.b    0,0
  13757.         dc.l    0
  13758.         dc.l    0
  13759. IconXPos    dc.l    NO_ICON_POSITION        ; Position of icon
  13760. IconYPos    dc.l    NO_ICON_POSITION
  13761.         dc.l    0
  13762.         dc.l    0
  13763.         dc.l    0
  13764. MyAppIconText    dc.b    "KCommodity",0
  13765.         EVEN
  13766.  
  13767.  
  13768.  
  13769. **********************************************************************
  13770. *                 Structures for the Tools-MenuItem                  *
  13771. **********************************************************************
  13772. MAINITEM    EQU    1
  13773.  
  13774.  
  13775.  
  13776. **********************************************************************
  13777. *                       Texts for localization                       *
  13778. **********************************************************************
  13779. LOCALE_START
  13780. * CATALOG kcxmain
  13781. * VERSION 2.5
  13782. * DATE 01.02.93
  13783. DefFormTitle        dc.b    "Formatter : HotKey=",0
  13784. * D                "Formatierer : HotKey=",0
  13785. DefBillTitle        dc.b    "Bill : HotKey=",0
  13786. * D                "Rng. : HotKey=",0
  13787. DefSelScrTitle        dc.b    "Screen Select : HotKey=",0
  13788. * D                "Screen Wahl : HotKey=",0
  13789. DefLabel        dc.b    "Empty",0
  13790. * D                "Leer",0
  13791. CommandHeader        dc.b    "KCommodity, error occured ",0
  13792. * D                "KCommodity, Fehler aufgetreten",0
  13793. GlobalTagName        dc.b    "*** GLOBALTAG ***",0
  13794. * D                "*** GLOBALER TAG ***",0
  13795. NoScrName        dc.b    "? NO NAME ?",0
  13796. * D                "? KEIN NAME ?",0
  13797. QuitText        dc.b    "Do you really want to quit KCommodity ?",0
  13798. * D                "Wollen Sie KCommodity wirklich beenden ?",0
  13799. QuitGads        dc.b    "Sure|No",0
  13800. * D                "Sicher|Nein",0
  13801. FormatWin        dc.b    "CON:0/11//90/KCX-Formatter Shell",0
  13802. * D                "CON:0/11//90/KCX-Formatier Shell",0
  13803. OnlineFormStr        dc.b    "Online ",0
  13804. * D                "Anschluß ",0
  13805. EString            dc.b    "E",0
  13806. * D                "L",0
  13807. FString            dc.b    "F",0
  13808. * D                "V",0
  13809. BrokerTitle        dc.b    "KCommodity by Kai Iske",0
  13810. * D                "KCommodity von Kai Iske",0
  13811. BrokerDesc        dc.b    "Multifunction commodity. ShareWare",0
  13812. * D                "Multifunktionale Commodity. ShareWare",0
  13813. DoFormatText        dc.b    "You have inserted an unformatted disk",10
  13814.             dc.b    "in drive %s",10
  13815.             dc.b    "Would you like to format the disk ?",0
  13816. * D                "Sie haben eine unformatierte Diskette",10
  13817. * D                "in Laufwerk %s eingelegt.",10
  13818. * D                "Wollen Sie die Diskette formatieren ?",0
  13819. FormatGads        dc.b    "YES|NO",0
  13820. * D                "JA|NEIN",0
  13821. WindowScrTitle        dc.b    "KCommodity by Kai Iske. ShareWare",0
  13822. * D                "KCommodity von Kai Iske. ShareWare",0
  13823. LogWinTitle        dc.b    "Enter a Log Message",0
  13824. * D                "Geben Sie eine Log Nachricht ein",0
  13825. PurposeWinTitle        dc.b    "Enter a Purpose Message",0
  13826. * D                "Geben Sie eine Zweck-Nachricht ein",0
  13827. AlarmReqText        dc.b    "Hey guy,",10,"It`s time for you to wake up !",0
  13828. * D                "Hey Du,",10,"Es ist Zeit aufzuwachen !",0
  13829. PerHourStr        dc.b    "Costs per hour : ",0
  13830. * D                "Kosten pro Stunde : ",0
  13831. FormTMemString        dc.b    " Total Memory : %8ld ",0
  13832. * D                " Ges. Speicher : %8ld ",0
  13833. FormSnapMemStr        dc.b    " Snapped  C: %7ld   F: %8ld ",0
  13834. * D                " Schnap.  C: %7ld   F: %8ld ",0
  13835. LogEntryFormat        dc.b    "%9.9s: %8.8s - %8.8s / Zone %ld Tariff %c / Time %02ld:%02ld:%02ld / Cost %ld.%02ld",10,0
  13836. * D                "%9.9s: %8.8s - %8.8s / Zone %ld Tarif  %c / Zeit %02ld:%02ld:%02ld / Geld %ld.%02ld",10,0
  13837. NormChar        dc.b    "N",0
  13838. * D                "N",0
  13839. CheapChar        dc.b    "C",0
  13840. * D                "B",0
  13841. AppMenuTxt        dc.b    "KCX Preferences",0
  13842. * D                "KCX Einstellungen",0
  13843. DriveText        dc.b    "_Drive",0
  13844. * D                "_Laufwerk",0
  13845. LabelText        dc.b    "_Label",0
  13846. * D                "_Name",0
  13847. TrashcanText        dc.b    "_Trashcan",0
  13848. * D                "_Papierkorb",0
  13849. QuickText        dc.b    "_Quick",0
  13850. * D                "_Schnell",0
  13851. FFSText            dc.b    "_FFS",0
  13852. * D                "_FFS",0
  13853. NoVerifyText        dc.b    "No _Verify",0
  13854. * D                "Kein _Verify",0
  13855. InstallText        dc.b    "_Install",0
  13856. * D                "_Installieren",0
  13857. EjectText        dc.b    "_Eject",0
  13858. * D                "A_uswerfen",0
  13859. FormOkText        dc.b    "F_ormat",0
  13860. * D                "F_ormatieren",0
  13861. FormCancelText        dc.b    "_Cancel",0
  13862. * D                "_Abbruch",0
  13863. WatchDisksText        dc.b    "_Watch disks",0
  13864. * D                "_Überwache Disk.",0
  13865. DiskCacheText        dc.b    "Di_rectory-Cache",0
  13866. * D                "Ve_rzeichnis-Cache",0
  13867. IntModeText        dc.b    "Intern. _Mode",0
  13868. * D                "Intern. Mo_dus",0
  13869. WatchTxt1        dc.b    "DF_0:",0
  13870. * D                "DF_0:",0
  13871. WatchTxt2        dc.b    "DF_1:",0
  13872. * D                "DF_1:",0
  13873. WatchTxt3        dc.b    "DF_2:",0
  13874. * D                "DF_2:",0
  13875. WatchTxt4        dc.b    "DF_3:",0
  13876. * D                "DF_3:",0
  13877. BillTimeMXLab0        dc.b    "Time _1",0
  13878. * D                "Zeit _1",0
  13879. BillTimeMXLab1        dc.b    "Time _2",0
  13880. * D                "Zeit _2",0
  13881. BillTimeMXLab2        dc.b    "Time _3",0
  13882. * D                "Zeit _3",0
  13883. BillCheapLab0        dc.b    "Normal _4",0
  13884. * D                "Normal _4",0
  13885. BillCheapLab1        dc.b    "Cheap _5",0
  13886. * D                "Billig _5",0
  13887. BillTimeText        dc.b    "Time",0
  13888. * D                "Zeit",0
  13889. BillOnlineText        dc.b    "Online",0
  13890. * D                "Anschluß",0
  13891. BillCostText        dc.b    "Cost",0
  13892. * D                "Kosten",0
  13893. BillStartText        dc.b    "_Start",0
  13894. * D                "_Start",0
  13895. BillStopText        dc.b    "Sto_p",0
  13896. * D                "Sto_p",0
  13897. LogCallText        dc.b    "_Log call",0
  13898. * D                "_Anruf speichern",0
  13899. LogOkText        dc.b    "_Ok",0
  13900. * D                "_Ok",0
  13901. LogCancelText        dc.b    "_Cancel",0
  13902. * D                "_Abbruch",0
  13903. LogVerText        dc.b    "_Revision",0
  13904. * D                "_Revision",0
  13905. LogOnlyTextText        dc.b    "_Only Text",0
  13906. * D                "_Nur Text",0
  13907. ProgWinWTitle        dc.b    "Revision in progress",0
  13908. * D                "Revision in Arbeit",0
  13909. SelScrWinWTitle        dc.b    "Screen-List : Select new screen",0
  13910. * D                "Screen-Liste : Wählen Sie einen neuen Screen",0
  13911. TaskListText        dc.b    "_List",0
  13912. * D                "_Liste",0
  13913. SelScrActText        dc.b    "_Activate",0
  13914. * D                "A_ktivieren",0
  13915. SelScrCancelText    dc.b    "_Cancel",0
  13916. * D                "_Abbruch",0
  13917. SelScrNumScrText    dc.b    "Number of Screens",0
  13918. * D                "Anzahl Screens",0
  13919. SelScrDefPubText    dc.b    "Default Pub-Screen",0
  13920. * D                "Voreingest. Pub-Screen",0
  13921. SelScrUpdateText    dc.b    "_Update list",0
  13922. * D                "Liste erne_uern",0
  13923. CliHelpPage        dc.b    10,10,"KCommodity by Kai Iske. ShareWare",10
  13924.             dc.b    "USAGE : KCommodity",10
  13925.             dc.b    "  ToolType :          Description :              Default :",10
  13926.             dc.b    "  -----------------------------------------------------------------------",10
  13927.             dc.b    "  [CX_PRIORITY=n]     Priority of Broker         5",10
  13928.             dc.b    "  [CX_POPKEY=s]       PopUpKey for Window        LCOMMAND HELP",10
  13929.             dc.b    "  [CX_POPUP=YES|NO]   PopUp on startup           YES",10
  13930.             dc.b    "  [PORTNAME=s]        Set name for ARexx-Port    KComm.1",10
  13931.             dc.b    "  [TOOLPRI=n]         Priority for Program       0",10
  13932.             dc.b    "  [HANDLERPRI=n]      Priority for Handler       55; must be >= 51",10
  13933.             dc.b    "  [SETTINGS=s]        New filename for Prefs     ENV:KCX/KCX.PREFS",10
  13934.             dc.b    "  [PREFSPATH=s]       New path for Prefs-Prg     SYS:PREFS/KCommodity",10
  13935.             dc.b    "  [PRINTERPATH=s]     New path for printer       SYS:Utilities/KCXPrinter",10
  13936.             dc.b    "  [NOICON]            Don`t display AppIcon      ---",10
  13937.             dc.b    "  [NOMENU]            Don`t add AppMenuItem      ---",10
  13938.             dc.b    "  [ICONX]             X-Position for AppIcon     FINDBEST",10
  13939.             dc.b    "  [ICONY]             Y-Position for AppIcon     FINDBEST",10
  13940.             dc.b    "  [NOREQ]             Disable Quit-Requester     ---",10,10,10,0
  13941. * D                10,10,"KCommodity von Kai Iske. ShareWare",10
  13942. * D                "Benutzung : KCommodity",10
  13943. * D                "  ToolType :          Beschreibung :             Voreingestellt :",10
  13944. * D                "  -----------------------------------------------------------------------",10
  13945. * D                "  [CX_PRIORITY=n]     Priorität des Brokers      5",10
  13946. * D                "  [CX_POPKEY=s]       PopUpKey für Window        LCOMMAND HELP",10
  13947. * D                "  [CX_POPUP=YES|NO]   PopUp beim Starten         YES",10
  13948. * D                "  [PORTNAME=s]        Name des ARexx-Ports       KComm.1",10
  13949. * D                "  [TOOLPRI=n]         Priorität des Programms    0",10
  13950. * D                "  [HANDLERPRI=n]      Priorität des Handlers     55; muß >= 51 sein",10
  13951. * D                "  [SETTINGS=s]        Neuer Filename für Prefs   ENV:KCX/KCX.PREFS",10
  13952. * D                "  [PREFSPATH=s]       Neuer Pfad für Prefs-Prg   SYS:PREFS/KCommodity",10
  13953. * D                "  [PRINTERPATH=s]     Neuer Pfad für Printer     SYS:Utilities/KCXPrinter",10
  13954. * D                "  [NOICON]            Kein AppIcon zeigen        ---",10
  13955. * D                "  [NOMENU]            Kein AppMenuItem zeigen    ---",10
  13956. * D                "  [ICONX]             X-Position des AppIcon     BESTE FINDEN",10
  13957. * D                "  [ICONY]             Y-Position des AppIcon     BESTE FINDEN",10
  13958. * D                "  [NOREQ]             Ende-Requester unterbinden ---",10,10,10,0
  13959. LOCALE_END
  13960.  
  13961.  
  13962.  
  13963.  
  13964.         SECTION    Chips,DATA_C
  13965.  
  13966.  
  13967. **********************************************************************
  13968. *                           Sound of click                           *
  13969. **********************************************************************
  13970. ClickData    dc.w    -512,-256,-128,-64,-32,0,32,64,128,256,512
  13971. CLICKLEN    EQU    (*-ClickData)
  13972.  
  13973.  
  13974. **********************************************************************
  13975. *                         Clear sprite data                          *
  13976. **********************************************************************
  13977. NoSpriteDat    ds.l    1
  13978.         ds.l    1
  13979.         ds.l    1
  13980.  
  13981.  
  13982.         INCLUDE    KCX.BSS
  13983.         END
  13984.